Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have the following expression, which displays data for the current week in a KPI:
Sum({<date={">=$(=Weekstart(max(date)))<=$(=Weekend(max(week_date)))"}>}[Total Customers])
I would like to display the previous weeks figure in the secondary KPI, but I just can't seem to find the right answer. If anybody here can help, I would be extremely grateful.
May b this
Sum({<[ Date] = {'$(=Date(Max([ Date])-7))'}>} customer)
=sum({<date={"=inweek(Date,today(1),-1)"}>} customers)
That's along the right lines, but it gives an output which adds up a total of all the customers from all previous weeks.
What I need is to just show the previous weeks figure alone.
Many thanks for your help.
The first one should work but try below
Something like this
sum({<OrderDate={">=$(=Date(today()-7,'MM/DD/YYYY'))<=$(=Date(today(),'MM/DD/YYYY'))"}>}Sales)
Change the Date format 'MM/DD/YYYY' to whatever format you have in OrderDate
Hi @Chanty4u - your help has got me closer to a solution, but I'm still not quite there. The following code gets me the calculation I want (current week - previous week), but it does not work when any filters are applied. Might you possibly know why this is?
Sum({<date={">=$(=Weekstart(max(date)))<=$(=Weekend(max(week_date)))"}>}[Total Customers])
-
Sum({<date ={">=$(=Weekstart(max(date),-1))<=$(=Weekend(max(date),-1))"},Week=>}[Total Customers])
try more simpler way
create week in your script use like below.
Sum({$<week={$(=Max(week)}[Total cust])_Sum({$<week={$(=Max(week)-1}[Total cust])
for your query- try to keep in two kpi objects for two measures and test its working or not.