Forum Discussion
How to turn multiple SQL joins into DAX? Example challenge
- 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:
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!
- Anonymous4 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.
- Anonymous4 years agoNot applicable
Hi Valterri, I just tried this formula and encountered a strange error prompt "an invalid numeric representation of a date value was encountered", do you happen to know what does it mean?
- ValtteriN4 years agoCommunity Champion
Hi,
I would check whether or not you have NULL values and also what is the data format of your columns. These might be the reason for this error.- Anonymous4 years agoNot applicable
Hi, thank you again. I guess u r right there might be something with the original data. I don't see any null value or data type issue but when I reimported the original date data it was solved. Thank you very much again!