Forum Discussion
SAMEPERIODLASTYEAR() and TOTALYTD() functions
Hi,
I have an issue with functions SAMEPERIODLASTYEAR() and TOTALYTD().
I have one date filter and I have chosen interval 1.1.2024-30.9.2024.
I have this kind of data:
I have these measures:
Sum Amount = TOTALYTD(SUM(Table[Amount]))
Amount diff vs LY = [Sum Amount] - CALCULATE([Sum Amount], SAMEPERIODLASTYEAR(Calendar[Date]))
This "Amount diff vs LY" measure doesn't work right. Now it should give
because 12-13 = -1 but it gives me 12.
I think it's because there is "Species 1" and "Species 2". Measures and tables without date duplicates works fine (and when relationships are 1:1). What should I do? And this is only a problem when I have chosen this date interval 1.1.2024-30.9.2024. If I choose for example just September, it works well. But I have to choose all the months because I want all of them to other graphs on the same page.
Thanks for your help!
3 Replies
- SamWiseOwl
Super User
- JulkorFrequent Visitor
Hi,
Actually I was unclear yesterday. When I put Table[Date] to second measure, it gives me the same result as measure "Sum Amount".
But when I use Calendar[Date] in second measure, it gives me this error: "Calculation error in measure. Function 'SAMEPERIODLASTYEAR' expects a contiguous selection when the date column comes from a table on the 1-side of a bi-directional relationship."
I am not sure what selection is not contiguous. I have one filter on and its YEAR = 2024.
What should I do?
Thanks for your help!
- AnonymousNot applicable
Hi, Julkor
Thanks for SamWiseOwl's reply. Since it is not possible to reproduce your problem, at this point are you able to share the pbix file without sensitive data for testing. Feel free to help you.Best Regards,
Yang
Community Support Team