Forum Discussion
Help with previous day calculation
I am trying to create the below visual;
I have implemented this DAX, and it will not bring back the correct figures?
Total Installs Yesterday - iOS = CALCULATE([Total Installs],dateadd(DateDimension[Date],-1,DAY))
Total Installs Previous Day - iOS = CALCULATE([Total Installs],dateadd(DateDimension[Date],-2,DAY))
I have even tried the below;
Yesterday iOS = CALCULATE(SUM('iOS - App Units'[Installations]),PREVIOUSDAY('iOS - All App Units'[Date]))
I ahve tried with both a Dimdate and the date in the table.
And this also comes back with the incorrect number, I have a visual with the total installs with a filter on it so I know what figure I should be getting back;
Thanks
Hi, Anonymous
Based on your description, I assume that you want to calculated the installs yesterday and the installs the day before yesterday. I created data to reproduce your scenario.
Table:
You may create measures as below.
Yesterday = CALCULATE( SUM('Table'[Installs]), FILTER( ALLSELECTED('Table'), 'Table'[Date]=TODAY()-1 ) ) The day before yesterday = CALCULATE( SUM('Table'[Installs]), FILTER( ALLSELECTED('Table'), 'Table'[Date]=TODAY()-2 ) )Today is 6/26/2020. Here is the result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
4 Replies
- amitchandakSuper User
Anonymous , Do with Date table only.
Mark your date dimension as date table.
Check does date has timestamp. Change datatype to datetime, choose a format to see time. If it has time then create date column join that with date table
New date = Table[Date].Date
- aj1973Community Champion
Hi Anonymous
This formula is not correct Yesterday iOS = CALCULATE(SUM('iOS - App Units'[Installations]),PREVIOUSDAY('iOS - All App Units'[Date])): PREVIOUSDAY Function works better with your DateDimension Table.
Did you create a Day Column in your DateDimension Table? if yes then try using PREVIOUSDAY function in your other 2 measures instead of DATEADD!
Maybe a Dummy Pibx file could help better understand your issue.
Regards
- v-alq-msftCommunity Support
Hi, Anonymous
Based on your description, I assume that you want to calculated the installs yesterday and the installs the day before yesterday. I created data to reproduce your scenario.
Table:
You may create measures as below.
Yesterday = CALCULATE( SUM('Table'[Installs]), FILTER( ALLSELECTED('Table'), 'Table'[Date]=TODAY()-1 ) ) The day before yesterday = CALCULATE( SUM('Table'[Installs]), FILTER( ALLSELECTED('Table'), 'Table'[Date]=TODAY()-2 ) )Today is 6/26/2020. Here is the result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- AnonymousNot applicable