Forum Discussion

aashton's avatar
aashton
Helper V
1 year ago
Solved

Summing measures from different tables

In Power BI, I have an Hours Worked table with the fields Provider NPI, Facility, Contract Type, Provider Type, Total Hours.  This links many to one to a Headcount table, on NPI, where I get this pro...
  • Bibiano_Geraldo's avatar
    Bibiano_Geraldo
    1 year ago

    Hi try The following steps:

    1- Create Measure for Hourly Rate

    Hourly Rate = 
    CALCULATE(
        MAX(Rates[Hourly Rate]),
        FILTER(
            Rates,
            Rates[Facility] = SELECTEDVALUE('Hours Worked'[Facility]) &&
            Rates[Provider Type] = RELATED(Headcount[Provider Type]) &&
            Rates[Contract Type] = RELATED(Headcount[Contract Type])
        )
    )

     

    2- Create Measure for Scheduled Weekly Hours

    Scheduled Weekly Hours = 
    CALCULATE(
        SUM(Headcount[Scheduled Weekly Hours]),
        FILTER(
            Headcount,
            Headcount[NPI] = RELATED('Hours Worked'[Provider NPI])
        )
    )

     

    3- Calculate Total Pay

    Total Pay = 
    SUMX(
        'Hours Worked',
        'Hours Worked'[Total Hours] * [Hourly Rate]
    ) + 
    SUMX(
        Headcount,
        [Scheduled Weekly Hours] * [Hourly Rate]
    )

     

    Dont forget to double check the table and column names.

    Thank you.