Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hello Power BI community,
I have a question regarding the automation of year change in my PBI measures.
Here is the link to download my sample workbook https://drive.google.com/file/d/1V-aJWENneBT4TlCo4ZyWK0RW9IRE7jVa/view?usp=share_link
Currently, in the measure named "Test", I used a specific year (such as 2022) to illustrate the idea that when it is the current year, the measure shows Total YTD figures while in historical years, it shows full-year data (disregard the year slicer). The weakness of this measure is the manual change of year 202x in the "Test" measure when it comes to a new year.
I am thinking that I can replace 2022 with the formula year(today()) but the problem is that in January 2023 we started consolidating data of December 2022, and if I replace 2022 with year(today()), I would not be able to use month slicer to interact with YTD figures in 2022.
Does anyone have any idea how I can automatically replace the manual change of year (which is 2022 in the sample data)?
Many thanks in advance and Happy new year to everyone in our community.
@TracyHT , One of the way to get YTD based on today
YTD Today =
var _min = eomonth(today(),-1*month(today()))+1
var _max = today()
return
CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
Based on selected date of today
YTD =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomonth(_max,-1*MONTH(_max))+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))
You can put additional conditions to have YTD this year after Jan
example
YTD Today =
var _max1 = today()
Var _max - if(month(_max1) =1, eomonth(_max1,-1) , _max1)
var _min = eomonth(_max ,-1*month(_max ))+1
return
CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))
@amitchandak Thank you for your solution but I'm not really clear.
Does that mean I should create 3 more measures? Should I replace "2022" in my measure with the measure below?
You can put additional conditions to have YTD this year after Jan
example
YTD Today =
var _max1 = today()
Var _max - if(month(_max1) =1, eomonth(_max1,-1) , _max1)
var _min = eomonth(_max ,-1*month(_max ))+1
return
CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))