Forum Discussion
Last week calculation
A collegue of mine wrote the dax stated below, and it worked. Unfortunately not when we started the new year.
Then it looks for week 0 (week 1 minus 1), and it obviously can't find it.
My idea would be that I need to adjust this VAR:
VAR MaxWeekNumber = CALCULATE(MAX(Datetabel[Weeknr])-1, ALL(Datetabel))
MAX(Datetabel[Weeknr]) where YEAR(today())-1
But how can I write this in DAX??
I hope everything is clear and someone can help me out on this.
thanks in advance!
Sander1401 I would recommend implementing something like Sequential and then this is trivial. Can also do something similar in PQ. https://community.powerbi.com/t5/Quick-Measures-Gallery/Sequential/m-p/380231#M116
4 Replies
- Greg_DecklerCommunity Champion
Sander1401 I would recommend implementing something like Sequential and then this is trivial. Can also do something similar in PQ. https://community.powerbi.com/t5/Quick-Measures-Gallery/Sequential/m-p/380231#M116
- Sander1401Helper II
Greg_DecklerGood suggestion, thanks for that. I only are having troubles with the iso weeks/year. So the first 2 days of 2022 (1 january and 2 january 2022) are in Iso week 52-2021. But unfortunately the column calculation doesn't recognize this...
How can I solve this? Do you have an idea?
- Greg_DecklerCommunity Champion
Sander1401 Make sure you are using the right return type for WEEKNUM:
- Sander1401Helper II
Greg_Deckler I forgot to change one VAR, my mistake, it works now! Thanks again!