How to do YTD 2022, 2021 in Tabular Editor to use in PowerBI

0 Reputation points
2023-03-09T22:38:22.9+00:00
``````I am trying to get this formula to work in Tabular Editor - Calculation Group to use in PowerBI. I don't care if it is a calculation group or Advanced Scripting. Just want to create for the time periods YTD 2023 (that one is easy), YTD 2022, YTD 2021, YTD 2020 and YTD 2019.  So all periods will show 1/1 - 3/4 (or latest date) for each of those 5 years.

This is my PowerBi measure and it works:

YTD 2022 Margin = calculate(Margin \$],Filter(ALL(Dates), Dates[Year] = Max(Dates[Year]) - 1  && Dates

[MonthSequentialNumber] <= Max(Dates[MonthSequentialNumber]) - 12) )

This is what I have in Tabular Editor and it gives me the WHOLE year for 2022 vs YTD through Feb 2022

calculate(
selectedmeasure (),
filter (ALL(Dates), Dates[Year] = Max(Dates[Year]) - 1  && Dates [MonthSequentialNumber] <= Max(Dates[MonthSequentialNumber]) - 12)
)

I am not proficient in anything Dax, coding and pretty much everything I do I have to watch a video, so HELP please!
``````
Not Monitored
--please don't forget to `upvote` and `Accept as answer` if the reply is helpful--