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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Casiqueno
Frequent Visitor

TOTALYTD based on relative measure

Good afternoon experts!
I need to create a measure in order to provide me with the monthly accumulated value (i.e. TOTALYTD) of a measure.
The measure is the relative consumption of energy per staff calculated according to the following formula:

Relative = DIVIDE(DIVIDE(SUM(Energy[Consumption]),1000),SUM('Staff number'[Staff+Support]))

January: 0.41 MWh/staff
February: 0.36 MWh7staff
...
What is needed here is quite simple but I get stuck: using TOTALYTD, I would like to have February displaying 0.77 MWh/staff.

I have tried with the formula:

YTD Cumulative 2 = IF(ISBLANK(SUM(Energy[Consumption])), BLANK(), TOTALYTD([Relative],'Date'[Date]))

But no way...

It would be more than welcome if you could give me some advice or telling what I'm doing wrong 🙂

Thank you very much!

Link to pbix: https://drive.google.com/file/d/1GaXXH4D53Z7-B3CZtU_YQ0ew61Mouold/view?usp=sharing
1 ACCEPTED SOLUTION
jdbuchanan71
Super User
Super User

Hello @Casiqueno 

Give this a try.

YTD RT = 
VAR FinalDate = MAX ( Energy[Date] )
VAR MonthStart = FIRSTDATE ( 'Date'[Date] )
RETURN
IF ( MonthStart > FinalDate, blank(),
CALCULATE ( SUMX ( VALUES ( 'Date'[Month_Year] ), [Relative] ), DATESYTD( ( 'Date'[Date] ) ) ) )

ytdrt.jpg

View solution in original post

2 REPLIES 2
jdbuchanan71
Super User
Super User

Hello @Casiqueno 

Give this a try.

YTD RT = 
VAR FinalDate = MAX ( Energy[Date] )
VAR MonthStart = FIRSTDATE ( 'Date'[Date] )
RETURN
IF ( MonthStart > FinalDate, blank(),
CALCULATE ( SUMX ( VALUES ( 'Date'[Month_Year] ), [Relative] ), DATESYTD( ( 'Date'[Date] ) ) ) )

ytdrt.jpg

Hi @jdbuchanan71 ,

this works perfectly! Thank you very much for your very valuable help on this matter and your rapid answer!

I will now try to understand the logic behind :-).

Thank you again!

Regards,

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.