Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I want to get the last month's Sum of sales.
I use a variable called vLastMonth:
= Text (Year (Today ())) & '-' & Month (AddMonths (Today (), - 1))
And this is the formula to get the Sum of last month's sales:
Sum ({$ <[Order Date.autoCalendar.YearMonth] = {"vLastMonth"}>} Sales)
But the result is: 0.
Why?
If I put "2020-Oct" it works.
Why does working with the variable fail?
I would also love to understand, why if I add $ to a variable
Sum ({$ <[Order Date.autoCalendar.YearMonth] = $ {"vLastMonth"}>} Sales)
I get the Sum of all sales without filtering of months (last month).
Thanks for your help
@Shoro you can try this :
=Sum ({$ <[Order Date.autoCalendar.YearMonth] = { '$(vLastMonth)' }>} Sales)
and check date format for Order Date.autoCalendar.YearMonth must be YYYY-MMM
and example :
I found that the correct formula is:
Sum ({$ <[Order Date.autoCalendar.MonthsAgo] = {1}>} [Sales])
But I would still love to understand why the previous formula does not work.
I think the reason why this Sum ({$ <[Order Date.autoCalendar.YearMonth] = $ {"vLastMonth"}>} Sales) didn't work is because you put the double quote and the dollar expansion ($) in the wrong place. See below
Sum ({$ <[Order Date.autoCalendar.YearMonth] = {"$(vLastMonth)"}>} Sales)
Hopefully this helps