Doug Creighton
07/24/2024, 3:09 PMMichal Hauzírek
07/24/2024, 3:13 PMDoug Creighton
07/24/2024, 3:15 PMDoug Creighton
07/24/2024, 3:15 PMMichal Hauzírek
07/24/2024, 3:55 PMBY ALL DateDimension
to convince the engine it can be sliced by that date. It will remove the warning/error. But if it is not compatible in the model (i.e. if fact/ssid_start is not connected to Timestamp date) it won’t make it work “for real”.Doug Creighton
07/24/2024, 3:56 PMDoug Creighton
07/24/2024, 5:53 PMJakub Sterba
07/24/2024, 8:06 PMSELECT MAX(SELECT CASE WHEN {label/attr1}="val1" THEN {metric/M1} ELSE {metric/m2} END BY attr1)
the BY rule will tell engine to compute both metrics m1 and m2 grouped by attr1 and either value of m1 or m2 will be used for the result depending on specified condition which will be evaluated on the same grain (which will include attr1 even if it is not used in the visualization). MAX will be used as aggregation function in case metric is not going to be sliced by attr1. {dataset/dataset_id} can be used in BY rule to specify grain of a dataset.
BY rule is even more important when THEN/ELSE contains a constant. Constant is just one number so BY rile will define at which grain will be evaluated the condition.
In general I would recommend to specify always BY rule for CASE statement and fill there:
• all attributes which are compared in the condition
• dataset identifier if the condition uses facts of a dataset
• attributes which define grain at which metric shall be computed if metric is used in the WHEN condition
+ aggregation function on top of it so that metric can be used at different grain than specified by the BY rule
In many cases CASE WHEN is not needed and you can use for example arithmetics with multiple metrics where each of them uses different WHERE condition.