Forum Discussion
Anonymous
4 years agoNot applicable
How to turn multiple SQL joins into DAX? Example challenge
Help will be very much appreciated! Say if I want to create a measure called "Prior_Sales", now I have two tables I can use - [dim_date] and [sales]. The result should be: given a particular ISO...
- 4 years ago
Hi,
In the case of comparing weeks you could use variables.
If your data format is like you described somethin like this should do:
e.g. [measure] =var _ISOWEEK = MAX(Isoweeks[ISOWeek])var _LY_ISOWEEK = CONCATENATE(LEFT(_ISOWEEK,4)-1,RIGHT(_ISOWEEK,2))returnCALCULATE(SUM(Isoweeks[Value]),ALL(Isoweeks),Isoweeks[ISOWEEK]=_LY_ISOWEEK)Example data:
End result:
ValtteriN
4 years agoCommunity Champion
Hi,
For calculating previous years values you can use SAMEPERIODLASTYEAR
[Sales LY]=
CALCULATE([Sales],SAMEPERIODLASTYEAR('Calendar'[Date]))
I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!
Anonymous
4 years agoNot applicable
Hi,
Thanks for your response and this is a great formula to know!
The issue here is that the requirement is to look at the same "ISO Weeks", which are usually not the same dates and it's what complicates the problem.