Hi team, I'm having issues with the output of a m...
# gooddata-cloud
e
Hi team, I'm having issues with the output of a metric I have. The metric output is not affected by the filter of a visualization that it's used in. Its definition is really similar to another when which works as expected. I've replaced the
/edit
in the analyze view with
/debug
to see the generated SQL from GoodData, and in the broken metric, the visualization filter is not applied in the SQL, whereas in the above-mentioned similar working metric it does append the filter at the end of the SQL. Could someone take a look and explain why GoodData generates different SQLs for two metrics that are pretty much similar in definition? I can share the metric definitions and the generated SQLs over DM
m
Hi Emir, yes, please send over DM the metrics in question. Thanks.
1
Hi Emir, as agreed internally, I am sending over here my findings. After taking a look at both insights I found that if you want to make the insight that is not filtering correctly work, you will need to click on "show missing values" in the attribute. I had consulted this behaviour in the past and it works this way due to the logic behind the CASES and the connections in your LDM. Ideally the filters shall be pushed down in the SQL query in the backend, but such filter cannot be applied on a constant in branches of CASE which return constants. In such case the filter must be applied on the result. In case all branches are constants we have no option than to return values for all rows specified by attributes of visualization. In case only some branch returns vector of values for different attribute values, we can return the constant just for rows where the “main” branch returns some value. Even though the insight will filter correctly after using this "show missing values" feature, you will get empty rows for any additional attributes added to the insight. If you're looking to filter out rows where metrics return no data, I suggest trying something like:
HAVING {metric/your_metric} <> NULL
Another approach could be to apply constants only to rows that contain data. Instead of using a constant directly in the
THEN
clause, you might try something like:
SIGN({metric/utilized_-_spark_case_notes}) * 0
If you wish to make the filtering work without using the feature and removing the empty columns, then you would need to revisit your LDM to ensure that the connections between the attributes and facts used in the insight are optimal.