Forum Discussion

grkanth81's avatar
grkanth81
Icon for Helper II rankHelper II
1 year ago
Solved

Help need with creating this new measure

Hi all,

We are using Power BI Report Server (May 2025 version). 

Here is my sample test data:

Period table:

Period_integerFYPeriodper_begin_dateper_end_date
202401FY 2024Jul-231/07/202331/07/2023
202402FY 2024Aug-231/08/202331/08/2023
202403FY 2024Sep-231/09/202330/09/2023
202404FY 2024Oct-231/10/202331/10/2023
202405FY 2024Nov-231/11/202330/11/2023
202406FY 2024Dec-231/12/202331/12/2023
202407FY 2024Jan-241/01/202431/01/2024
202408FY 2024Feb-241/02/202429/02/2024
202409FY 2024Mar-241/03/202431/03/2024
202410FY 2024Apr-241/04/202430/04/2024
202411FY 2024May-241/05/202431/05/2024
202412FY 2024Jun-241/06/202430/06/2024
202501FY 2025Jul-241/07/202431/07/2024
202502FY 2025Aug-241/08/202431/08/2024
202503FY 2025Sep-241/09/202430/09/2024
202504FY 2025Oct-241/10/202431/10/2024
202505FY 2025Nov-241/11/202430/11/2024
202506FY 2025Dec-241/12/202431/12/2024
202507FY 2025Jan-251/01/202531/01/2025
202508FY 2025Feb-251/02/202528/02/2025
202509FY 2025Mar-251/03/202531/03/2025
202510FY 2025Apr-251/04/202530/04/2025

FTE table:

periodFE codeFTE
2025010001200
2025010002220
2025010003180
2025020001170
2025020002230
2025020003220
2025030001190
2025030002210
2025030003210
2025040001210
2025040002220
2025040003160
2025050001150
2025050002250
2025050003135
2025060001175
2025060002215
2025060003195
2025070001220
2025070002215
2025070003200

Hours table:

periodFE codeDisc_Hrs
2025010001600
2025010002500
2025010003700
2025020001500
2025020002600
2025020003650
2025030001450
2025030002500
2025030003390
2025040001450
2025040002550
2025040003625
2025050001500
2025050002525
2025050003670
2025060001635
2025060002475
2025060003590
2025070001585
2025070002655
2025070003490

 

I have created a new measure to get the Cumulative Hours by period as below:
CumulativeHrs = CALCULATE (
SUM ( Hours[Disc_Hrs] ),
FILTER (
ALLSELECTED ( Hours),
Hours[period]<= MAX (Hours[period] )
)
)

Now I would like to create another new measure which should be as per the below calculation:

 

For Jul2024 the calculation should be CumulativeHrsforJul2024/( (sum of FTE of the start period (Jul2024))/2)

For Aug2024 the calculation should be CumulativeHrsforAug2024/( (sum of FTE of the start period (Jul2024) + sum of FTE of the Aug2024)/2)

For Sep2024 the calculation should be CumulativeHrsforSep2024/( (sum of FTE of the start period (Jul2024) + sum of FTE of the Sep2024)/2)

For Oct2024 the calculation should be CumulativeHrsforOct2024/( (sum of FTE of the start period (Jul2024) + sum of FTE of the Oct2024)/2)

and so on...

Can someone help with creating a new measure as per the above calculation?

Thanks,,

grkanth81

 

  • Hi grkanth81 


    Welcome to the Microsoft Fabric Community Forum. Also, thank you ABD128 and Nasif_Azam for your quick responses.

     

    To calculate the required metric, follow the instructions where the cumulative hours for each month are divided by the average of the FTE from the start period (Jul-2024) and the FTE from the current period.

     

    Before creating the measure, ensure that the following relationships exist in the data model:

    • Period[Period_integer] → FTE[period]
    • Period[Period_integer] → Hours[period]


    Consider the below DAX:

     

    CumulativeHrsDivByAvgFTE = 
    VAR CurrentPeriod = MAX('Period'[Period_integer])
    
    VAR CumHrs =
        CALCULATE (
            SUM ( Hours[Disc_Hrs] ),
            FILTER (
                ALL ( 'Period' ),
                'Period'[Period_integer] <= CurrentPeriod
            )
        )
    
    VAR StartFTE =
        CALCULATE (
            SUM ( FTE[FTE] ),
            FILTER (
                ALL ( FTE ),
                FTE[period] = 202501
            )
        )
    
    VAR CurrentFTE =
        CALCULATE (
            SUM ( FTE[FTE] ),
            FILTER (
                ALL ( FTE ),
                FTE[period] = CurrentPeriod
            )
        )
    VAR AvgFTE = DIVIDE ( StartFTE + CurrentFTE, 2 )
    RETURN
        DIVIDE ( CumHrs, AvgFTE )
    

    Please refer attached Screenshot and .pbix file  for your reference and share your thoughts.


    If this helped solve the issue, please consider marking it “Accept as Solution” so others with similar queries may find it more easily. If not, please share the details, always happy to help.

    Welcome to the Microsoft Fabric Forum. Also, thank you  and  for your qucik responses.

     

    If this response resolves your query, kindly mark it as Accepted Solution to help other community members. A Kudos is also appreciated if you found the response helpful.

    Thank you for being part of Fabric Community Forum.

    Regards,
    Karpurapu D,
    Microsoft Fabric Community Support Team.

     

     



7 Replies

  • v-karpurapud's avatar
    v-karpurapud
    Icon for Community Support rankCommunity Support

    Hi grkanth81 


    Welcome to the Microsoft Fabric Community Forum. Also, thank you ABD128 and Nasif_Azam for your quick responses.

     

    To calculate the required metric, follow the instructions where the cumulative hours for each month are divided by the average of the FTE from the start period (Jul-2024) and the FTE from the current period.

     

    Before creating the measure, ensure that the following relationships exist in the data model:

    • Period[Period_integer] → FTE[period]
    • Period[Period_integer] → Hours[period]


    Consider the below DAX:

     

    CumulativeHrsDivByAvgFTE = 
    VAR CurrentPeriod = MAX('Period'[Period_integer])
    
    VAR CumHrs =
        CALCULATE (
            SUM ( Hours[Disc_Hrs] ),
            FILTER (
                ALL ( 'Period' ),
                'Period'[Period_integer] <= CurrentPeriod
            )
        )
    
    VAR StartFTE =
        CALCULATE (
            SUM ( FTE[FTE] ),
            FILTER (
                ALL ( FTE ),
                FTE[period] = 202501
            )
        )
    
    VAR CurrentFTE =
        CALCULATE (
            SUM ( FTE[FTE] ),
            FILTER (
                ALL ( FTE ),
                FTE[period] = CurrentPeriod
            )
        )
    VAR AvgFTE = DIVIDE ( StartFTE + CurrentFTE, 2 )
    RETURN
        DIVIDE ( CumHrs, AvgFTE )
    

    Please refer attached Screenshot and .pbix file  for your reference and share your thoughts.


    If this helped solve the issue, please consider marking it “Accept as Solution” so others with similar queries may find it more easily. If not, please share the details, always happy to help.

    Welcome to the Microsoft Fabric Forum. Also, thank you  and  for your qucik responses.

     

    If this response resolves your query, kindly mark it as Accepted Solution to help other community members. A Kudos is also appreciated if you found the response helpful.

    Thank you for being part of Fabric Community Forum.

    Regards,
    Karpurapu D,
    Microsoft Fabric Community Support Team.

     

     



    • grkanth81's avatar
      grkanth81
      Icon for Helper II rankHelper II

      Thanks karpurapud. I am looking into it. But you mentioned in your post you have attached pbix file but I couldn't find it. can you please attach it so I can refer to it ?

  • Hey grkanth81 ,

    Calculate your new measure based on the logic you've described.

    Objective

    You want a measure that:

    • Uses cumulative hours up to each period.

    • Divides that by the average of the FTE sum for:

      • Start period (always Jul-24, i.e. 202501).

      • And the current period.

    Steps

    For a given period:

    • Numerator: cumulative sum of Disc_Hrs from Hours table up to and including the current period.

    • Denominator: average of:

      • SUM(FTE) for start period (202501), and

      • SUM(FTE) for the current period.

    The DAX Measure

    CumulativeHrsAdjusted = 
    VAR StartPeriod = 202501
    
    VAR CurrentPeriod = MAX(Hours[period])
    
    -- Cumulative Disc_Hrs up to the current period
    VAR CumulativeHrs =
        CALCULATE(
            SUM(Hours[Disc_Hrs]),
            FILTER(
                ALL(Hours),
                Hours[period] <= CurrentPeriod
            )
        )
    
    -- FTE for Start Period (Jul-24)
    VAR StartPeriodFTE =
        CALCULATE(
            SUM(FTE[FTE]),
            FTE[period] = StartPeriod
        )
    
    -- FTE for Current Period
    VAR CurrentPeriodFTE =
        CALCULATE(
            SUM(FTE[FTE]),
            FTE[period] = CurrentPeriod
        )
    
    -- Average of Start + Current FTE
    VAR AvgFTE = DIVIDE(StartPeriodFTE + CurrentPeriodFTE, 2)
    
    -- Final adjusted value
    RETURN
    DIVIDE(CumulativeHrs, AvgFTE)

     

    Things to remember

    • DIVIDE() is used to safely handle divide-by-zero cases.

    • The measure uses MAX(Hours[period]) assuming you are slicing by Period and need the latest visible period.

    • If you are slicing by a Period table instead, just replace MAX(Hours[period]) with MAX(Period[Period_integer]).

     

    If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.


    Best Regards,
    Nasif Azam

  • ABD128's avatar
    ABD128
    Icon for Resolver II rankResolver II

    Hi grkanth81 

     

    Try the below DAX:

     

    CumulativeHrsDivByAvgFTE =

    VAR CumHrs =

    CALCULATE (

    SUM ( Hours[Disc_Hrs] ),

    FILTER (

    ALLSELECTED ( 'Period'[Period_integer] ),

    'Period'[Period_integer] <= MAX ( 'Period'[Period_integer] )

    )

    )

    VAR StartFTE =

    CALCULATE (

    SUM ( FTE[FTE] ),

    FTE[period] = 202501

    )

    VAR CurrentFTE =

    CALCULATE (

    SUM ( FTE[FTE] ),

    FTE[period] = MAX ( 'Period'[Period_integer] )

    )

    VAR AvgFTE = DIVIDE( StartFTE + CurrentFTE, 2 )

    RETURN

    DIVIDE( CumHrs, AvgFTE )