Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I need help getting last 12 months. Below is the set expression I used which worked fine until December. Now I get just last month. I would appreciate suggestions on how to fix this. Thanks
AVG({< Last12Months = {1}, DateType={'New'}>}[Time To Assign Hours])
I'd suggest looking into the generation of your Last12Months field. How is it generated?
My Last12Months field is generated as below
If("Canonical Date" < MonthStart(Floor(Today()))
And "Canonical Date" >= SetDateYear(MonthStart(MonthStart(Floor(Today()))-1),Year(Today())-1), 1, 0) As Last12Months
Your formula is for YTD not last 12 months.
We use:
Round((num(monthstart(Today(1))-num(monthstart(Date(TempDate)))))/30) AS MonthsFromCurrent
to create a flag of each month, then for last 12 you would set a filter for MonthsFromCurrent = {">1<=12"}
Thanks for your suggestions but this is what worked for me
If(("Canonical Date"<= Today() and "Canonical Date" >= MonthStart(Today(),-12)),1,0) AS Last12Months
Then I used the set expression below
Avg({<Last12Months = {1}, DateType = {'New'}>}[Time To Assign Hours])