Forum Discussion
Creating a Measure based on Previous day
- Anonymous6 years ago
You should use Today() instead of Now(), because Now()-1 return current time-1 second, not previous day. And for the sample you provided, you can test it by replace Today() with Date(2020,5,19) to check the average of 5/18.
Measure Calculate(divide(sum([Time ]),sum([Sales]),0),filter('Table',[Date]= TODAY()-1))Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
nosaj03 As a best practice, add date dimension in your model and use it for and time intelligence calculations. There are many posts on how to add date dimension and below is the link to a few. Once the date dimension is added, mark it as a date table on table tools.
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
https://radacad.com/create-a-date-dimension-in-power-bi-in-4-steps-step-1-calendar-columns
and then you can use something like this
Previous Day SAles =
CALCULATE ( SUM ( Table[SAles] ), DATEADD ( CalendarTable[Date], -1, DAY ) )
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!