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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
brief001
Helper II
Helper II

Sum using two relation tables

I'm looking for a DAX formula that calculates the sum using two other tables. One table shows how often a certain code occurs. And in a dimension table is the duration of this code. In the example below you can see what my question is exactly:

brief001_0-1634913702943.png

 

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @brief001 

 

Try this:

Measure =
VAR _Dur =
    ADDCOLUMNS(
        'Table 2',
        "Dur1",
            [Amount]
                * ( LOOKUPVALUE( 'Table 3'[Duration], 'Table 3'[Code], 'Table 2'[Code] ) )
    )
RETURN
    SUMX( _Dur, [Dur1] )

 

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

Appreciate your Kudos!!

 

View solution in original post

2 REPLIES 2
VahidDM
Super User
Super User

Hi @brief001 

 

Try this:

Measure =
VAR _Dur =
    ADDCOLUMNS(
        'Table 2',
        "Dur1",
            [Amount]
                * ( LOOKUPVALUE( 'Table 3'[Duration], 'Table 3'[Code], 'Table 2'[Code] ) )
    )
RETURN
    SUMX( _Dur, [Dur1] )

 

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

Appreciate your Kudos!!

 

Thank you VahidDM, this formula works exactly as hoped. 😀

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.