Felipe Porto
12/11/2021, 3:41 AMMichal Hauzírek
12/11/2021, 4:18 PMFelipe Porto
12/11/2021, 9:16 PMMichal Hauzírek
12/13/2021, 9:58 PMMichal Hauzírek
12/13/2021, 10:01 PMJakub Sterba
12/23/2021, 4:53 AMselect case
when Month/Year (Date 1)=this-5 then ifnull((select M2 by all other where Month/Year (Date 2)=this-5), 0),
when Month/Year (Date 1)=this-4 then ifnull((select M2 by all other where Month/Year (Date 2)=this-4), 0),
when Month/Year (Date 1)=this-3 then ifnull((select M2 by all other where Month/Year (Date 2)=this-3), 0),
when Month/Year (Date 1)=this-2 then ifnull((select M2 by all other where Month/Year (Date 2)=this-2), 0),
when Month/Year (Date 1)=this-1 then ifnull((select M2 by all other where Month/Year (Date 2)=this-1), 0),
when Month/Year (Date 1)=this then ifnull((select M2 by all other where Month/Year (Date 2)=this), 0)
end
The trick is I need to calculate value for specific data point as a one number which is not sliced by Date 2, e.g. using following statement for last month
(select M2 by all other where Month/Year (Date 2)=this-1)
where condition filters last month and :“by all other” tells that the metric will be not sliced by Date 2 so result is just one number which can be be repeated for each value of Date 1 dimension. The case statement will let me join tables with such scalars sliced by Date 1 and select appropriate scalar to create a vector of last 6 months. It may be needed to use ifnull function if there is a period in which M2 does not have any data.
It is quite complex workaround which comes with some limitations (you cannot drill by attribute or let user adjust the date filter etc.), but it can be handy if you need this just for only one specific visualization.Felipe Porto
01/05/2022, 6:16 PM