Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi,
A part of my code in my advance editor that builds my calendar table is the following:
...
#"Inserted Day of Year" = Table.AddColumn(#"==YTD QTD MTD Columns", "Day of Year", each Date.DayOfYear([Date]), Int64.Type),
#"Added Flag_YTD" = Table.AddColumn(#"Inserted Day of Year", "Flag_YTD", each if Date.DayOfYear([Date]) <= Date.DayOfYear(CurrentDate)
then "YTD"
...
else null)
and currentdate is defined as
CurrentDate = DateTime.Date(DateTime.FixedLocalNow())
If we consider that the date is 4 March 2024, then the YTD flag is true in the case of leap years (i.e. 2024 or 2020) but in the case of standard years (2023, 2022, 2021) it adds also the next day, 5th of March in the calculations of i.e. sales. So I actually do not compare apples to apples since for 2024 the total sales for March incude 1st, 2nd, 3rd and 4th of March but for year 2023 the total sales included 1st, 2nd, 3rd, 4th and 5th of March in the calculation.
How can we solve this?
EDATE([date],-12)
You wouldn't believe how much effort went into making that innocent looking function work reliably. It is truly an underappreciated gem.
Dear @lbendlin thank you for your prompt reply. Could you please be more specific? How will you modify my code? Can I insert the EDATE function in the advance editor?
It's a DAX function, not Power Query.
I agree, this is why I asked how we could modify the code in the advanced editor. My objective is to create a column in the Calendar table with the name "flag_YTD" and the use it as a slicer in the reports.
As far as I know there is no equivalent function for that in Power Query.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
15 | |
11 | |
11 | |
10 | |
10 |
User | Count |
---|---|
19 | |
14 | |
13 | |
11 | |
8 |