Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Divide by fixed calculated value, don't calculate for each ROW

Hi all,   Let me try to explain an issue I have.   I have a SALARY table like this: Date Salary Cost 01-01-2020 1110000 02-01-2020 1110000 03-01-2020 1110000 04-01-2020 1...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    Please use the following formula :

     

    Avg Cost Measure =
    VAR _time =
        CALCULATE (
            SUM ( 'Projects'[Time spend] ),
            FILTER (
                ALL ( 'Projects' ),
                MONTH ( 'Projects'[Date] ) = MONTH ( MAX ( 'Projects'[Date] ) )
            )
        )
    VAR _cost =
        CALCULATE (
            MAX ( 'Salary'[Salary Cost] ),
            FILTER (
                'Salary',
                MONTH ( 'Salary'[Date] ) = MONTH ( MAX ( 'Projects'[Date] ) )
            )
        )
    RETURN
        DIVIDE ( _cost, _time )
    Measure =
    MAX ( 'Projects'[Time spend] ) * [Avg Cost Measure]

     

    The final output is shown below:

     

    Here is the pbix file.

     

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