Hi team! I have a question on MAQL and dashboard ...
# gooddata-platform
j
Hi team! I have a question on MAQL and dashboard filters. I want to show a different metric based on the selected value of a parent filter. To exemplify: if I on my dashboard filter choose value A, the insight would display metric A and if I choose value B it would display metric B. And if I have no filter applied, it would show metric A, but if I apply a filter it would display metric B. Is this be possible somehow? Thanks! ๐Ÿ™‚
b
Hi Josefin, it probably won't be possible out of the box... but it depends on what you mean by different metrics? Do you want to do completely different visualizations? If not, there is an option to use case/if statement to implement some kind of decision mechanism within one metric. But the question is how many possible values would be in the filter.
Another option is to develop this using our UI.SDK dashboard plugins functionality - but you would need a react developer for that.
j
Hi Boris, I would like to have the same visualisation, but different metrics to be shown in the insight. This is due to depending on what level you are looking at the values for, different calculations need to be made. On an aggregated level itโ€™s done by metric A. but on a more granular level, itโ€™s done by metric B. So depending on if the filter is applied to the insight - it would have to display a different metric. So yes, perhaps this could be solved by a case /if statement in a metric, if it could have a decision mechanism based on if/which filter value has been applied to the dashboard?
b
it should be possible (of course depending on the specific use case). I could think of something like this
Copy code
SELECT IF(SELECT COUNT(attribute) WHERE attribute=value_A BY ALL OTHER) > 0 THEN metric_A ELSE metric_B;
In this simplified example you are basically checking if there's more than 0 lines with attribute value A - which would only be case if the value A is selected in the filter - then it would be showing metric A. If it's not selected metric B would shown. This approach might have some implications on how the LDM would have to be and would probably needed usage of WITH/WITHOUT PF, BY ALL OTHER (EXCEPT) keywords in the metrics and a lot of testing and experimentation but overall should be possible
j
Many thanks for the reply! This worked well ๐Ÿ™‚
p
๐ŸŽ‰ New note created.