Forum Discussion
Needs to have same dates in Previous Year Using DAX
Thanks Dale for your reply,
Your solution is very close to what i am required. We are already calculating LY Sale Measure. I try below with Existing Date Table.
Sales.LY During Offer Test:=
If(MIN(Sales[Offer Flag])=-1,BLANK(), CALCULATE([Sales LY])). When I put this in Card Visual It give me wrong result But when i put this in Table and put Dates on Rows it gives me only dates where Offer Flag <>-1 but total amount was wrong. To fix this I apply Visual level Filter on table of (Sales.LY During Offer Test is not Blank). Then I get correct result. but when I remove Date from Table again it give me wrong result.
I have question, Why we need Extra Date table? Can we do this without extra Date table.
I want to display Value in Card Visual. Let me try same like your Demo to create new Calendar date table. Then I will mark this as Solution.
Many Thanks indeed.
Azhar
Dear Dale,
I tried same model as of you in My SSAS Tabular Cube. I created New Date Table with just two columns from exsiting View of date. I mark this table as Date in model But My Measure TestMeasure:= CALCULATE(min('Offer Dates'[Date]),SAMEPERIODLASTYEAR('Offer Dates'[Date])) Always give me the first Date. So this is not working. Further Can you please add Year in Slicer from Dim_Date from in your demo PBIX and see Measure Values are disappeared.
What I am missing here please and why SamePeriodLastYear is not working.
- v-jiascu-msft7 years ago
Microsoft Employee
Hi Anonymous,
The SAMEPERIODLASTYEAR is a time intelligence function that needs a complete date table. There isn't one in the demo, so I created one.
Can you please point out which part is wrong in the DEMO? Please also post what the result should be based on the demo. To be honest, the result in the demo is right and it can be verified.
The measure always needs the context to evaluate. How did you test it in the SSAS? For example,
Date SAMEPERIODLASTYEAR
2018-01-10 2017-01-10 if there isn't a date 2018-01-10, how does the formula know which year is last year.
Best Regards,
Dale