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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
lukmtb08
Helper III
Helper III

DAX Related / SUMX

Dear community, 

 

my issue: I have two tables with a many-to-one relationship: 
T1

Data TypeValueMonth           key exchange rate 
YTD1000  
YTD2000  
YTD...  
Forecase3000  
Forecast2000  
Forecast...  

T2

key exchange ratevalue
......

 

I would like to calculate: (Amount Forecast - Amount YTD) * Value exchange rate

 

The value of the excahnge rate should be the one for forecast. I always calculate on a monthly basis, so I have just one value for all the forecast rows. The functionality of the related function with related is clear. But i do not understand how to solve my issue as I first have to calculate with more rows and in last step, with just one uniqe value. 

 

Thank you for your support. 

1 ACCEPTED SOLUTION
v-yadongf-msft
Community Support
Community Support

Hi @lukmtb08 ,

 

This is my test table 1:

vyadongfmsft_0-1669022351123.png

 

Test table 2:

vyadongfmsft_1-1669022379480.png

 

Relationship:

vyadongfmsft_2-1669022436903.png

 

Create a new column:

 

Column =
VAR sum_ytd =
    CALCULATE (
        SUM ( 'Table1'[Value] ),
        FILTER ( ALL ( 'Table1' ), 'Table1'[Data Type] = "YTD" )
    )
VAR sum_forecast =
    CALCULATE (
        SUM ( 'Table1'[Value] ),
        FILTER ( ALL ( 'Table1' ), 'Table1'[Data Type] = "Forecast" )
    )
VAR _value =
    MAXX (
        FILTER ( 'Table1', 'Table1'[Data Type] = "Forecast" ),
        RELATED ( 'Table2'[value] )
    )
RETURN
    ( sum_ytd - sum_forecast ) * _value

 

vyadongfmsft_3-1669022599863.png

 

Is this the result you want? Please refer the attached pbix file.

 

Best regards,

Yadong Fang

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

View solution in original post

3 REPLIES 3
v-yadongf-msft
Community Support
Community Support

Hi @lukmtb08 ,

 

This is my test table 1:

vyadongfmsft_0-1669022351123.png

 

Test table 2:

vyadongfmsft_1-1669022379480.png

 

Relationship:

vyadongfmsft_2-1669022436903.png

 

Create a new column:

 

Column =
VAR sum_ytd =
    CALCULATE (
        SUM ( 'Table1'[Value] ),
        FILTER ( ALL ( 'Table1' ), 'Table1'[Data Type] = "YTD" )
    )
VAR sum_forecast =
    CALCULATE (
        SUM ( 'Table1'[Value] ),
        FILTER ( ALL ( 'Table1' ), 'Table1'[Data Type] = "Forecast" )
    )
VAR _value =
    MAXX (
        FILTER ( 'Table1', 'Table1'[Data Type] = "Forecast" ),
        RELATED ( 'Table2'[value] )
    )
RETURN
    ( sum_ytd - sum_forecast ) * _value

 

vyadongfmsft_3-1669022599863.png

 

Is this the result you want? Please refer the attached pbix file.

 

Best regards,

Yadong Fang

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

Thank you very much! 🙂

amitchandak
Super User
Super User

@lukmtb08 , There few ways to copy data from one table to another

 

refer 4 ways to copy data from one table to another
https://www.youtube.com/watch?v=Wu1mWxR23jU
https://www.youtube.com/watch?v=czNHt7UXIe8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.