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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
mariomyhanh
Helper I
Helper I

Average calculation of FTE with switch of YTD and MTD

Hello , I need some help please. I'm struggling to wrap my head around some DAX needed to calculate the average FTE YTD depending on the month selection

I have a selection table with value column of:

current period
YTD

 and data set 

periodFTE Actualswould like to return value for YTD
sept

60

60

oct43.8351.92
nov44.13

49.32

dec43.2747.80
Jan40.2546.29

 

my current measure for current month is correct, but the YTD is returning the sum or total of all months and not the average.
MTD YTD Switch =
switch(
    True(),
    SELECTEDVALUE(SelectionTable[Value]) = "Current Period", [FTE-Actuals],
    SELECTEDVALUE(SelectionTable[Value])="YTD",TOTALYTD([FTE-Actuals],'Calendar'[Date],"8/31"),
    [FTE-Actuals]
    )
 
 

 

1 ACCEPTED SOLUTION

Thank you so much!

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @mariomyhanh ,

 

Please try this code to create a measure.

MTD YTD Switch =
VAR _SELECTVALUE =
    SELECTEDVALUE ( SelectionTable[Value] )
VAR _MONTH =
    MONTH ( MAX ( 'Calendar'[Date] ) )
VAR _MONTH_COUNT =
    IF ( _MONTH > 8, _MONTH - 8, _MONTH + 12 - 8 )
VAR _YTD =
    TOTALYTD ( SUM ( 'Table'[FTE Actuals] ), 'Calendar'[Date], "8/31" )
RETURN
    SWITCH (
        TRUE (),
        _SELECTVALUE = "Current Period", [FTE-Actuals],
        _SELECTVALUE = "YTD", DIVIDE ( _YTD, _MONTH_COUNT ),
        [FTE-Actuals]
    )

Result is as below.

RicoZhou_0-1665026677569.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Good morning, would you mind explaining what this mean please, the code works, but would like to understand the section below for future use.  Thank you

MONTH ( MAX ( 'Calendar'[Date] ) )
VAR _MONTH_COUNT =
    IF ( _MONTH > 8, _MONTH - 8, _MONTH + 12 - 8 )

 

Thank you so much!

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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