Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
VGoncalves
Regular Visitor

TotalYTD not working

Hello,

 

i have this measure:

HIRINGS_L1Y =
CALCULATE(SUM(BD_COLAB[HIRING]), DATESINPERIOD(DIM_DATES[Date], MAX(DIM_DATES[Date]), -13, MONTH))
 
This measure will give me, for example, for feb'22 i will have the sum of all the employee hirings from feb'21 and feb'22, it will give me, for example 200 hirings. But in jan'22 i will have 190 hirings
 
And after this, i want the YTD of hirings for each month  (i know it sounds weird, but its for a very specific reason), for example, for this example my YTD would be 390 YTD hirings 
 
But i did this measure:
HIRINGS_L1Y_YTD = TOTALYDT ([HIRINGS_L1Y], DIM_DATES[Date]) 
 
and is returning the samething i have on the previous measure, its not giving me the sum of the YTD. For feb'22 its giving me 200 hirings and not 390.
 
What am i doing wrong?
 
thank you
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@VGoncalves , try like

 

HIRINGS_L1Y =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomonth(_max,-1*MONTH(_max))+1
return
CALCULATE(Sumx(Values(DIM_DATES[Month Year]),
CALCULATE(SUM(BD_COLAB[HIRING]), DATESINPERIOD(DIM_DATES[Date], MAX(DIM_DATES[Date]), -13, MONTH))),DATESBETWEEN('Date'[Date],_min,_max))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@VGoncalves , try like

 

HIRINGS_L1Y =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomonth(_max,-1*MONTH(_max))+1
return
CALCULATE(Sumx(Values(DIM_DATES[Month Year]),
CALCULATE(SUM(BD_COLAB[HIRING]), DATESINPERIOD(DIM_DATES[Date], MAX(DIM_DATES[Date]), -13, MONTH))),DATESBETWEEN('Date'[Date],_min,_max))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak i was able to solve the difference of numbers, i did a separate measure for the ytd. thank you so much for your help!!

@amitchandak  i run again the measure, and still doesnt work, but the numbers arent that off. For jan'22 i have 378 hirings and for feb'22 i have 399 hirings, should give me a YTD of 777 hirings, but using your measure will give me 798 hirings.. its not that off, but isnt right

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.