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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Cross 2 table to calculate

Hi everyone,

I got a problem...it seems so simple but I actually cannot solve it 😞

 

Table 1

N°           Amount

C1            x

C2            y

 

Table 2

N°            Currency factor

C1             0

C2             1.12

 

And I would like :

Report Table

N°          Total Amount (if currency factor=0 => Amount, else => Amount/CurrFactor)

C1           x

C2           y/1.12

 

And I would like to have the sum = x+y/1.12

 

Is it easy?

Thank you so much

5 REPLIES 5
v-yulgu-msft
Employee
Employee

Hi @Anonymous,

 

If there is an existing relationship between 'Table1' and 'Table2', you could take Zubair_Muhammad's suggestion which can return expected result.

 

If there is no relationship between tables, you could try:

Total Amount =
IF (
    LOOKUPVALUE ( Table2[Currency Factor], Table2[N], Table1[N] ) = 0,
    Table1[Amount],
    Table1[Amount] / LOOKUPVALUE ( Table2[Currency Factor], Table2[N], Table1[N] )
)

When you add 'Table1'[N] and 'Table1'[Total Amount] into a table visual, it will automatically calculate the sum in Total row.

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

I can't choose Table1[N]...only the measures from the Table1...

So I create a measure on the Table1 with SUM(Amount).

 

Then, the LOOKUP issue doesn't work neither... 😞 Error!

Zubair_Muhammad
Community Champion
Community Champion

@Anonymous

 

Assuming there is a relationship between Table1 and Table2,

add this calculated column in Table1

 

Total Amount =
IF (
    RELATED ( Table2[Currency Factor] ) = 0,
    Table1[Amount],
    DIVIDE ( Table1[Amount], RELATED ( Table2[Currency Factor] ) )
)

Regards
Zubair

Please try my custom visuals
Anonymous
Not applicable

There is an active relationship (on N°) but it reacts as it does not. "RELATED" doesn't work...

 

So I can't write this lines (and I don't know why)...

Hi @Anonymous,

 

Since there is an active relationship, please try this:

Total Amount =
CALCULATE (
    IF (
        Table2[Currency Factor] = 0,
        Table1[Amount],
        DIVIDE ( Table1[Amount], Table2[Currency Factor] )
    ),
    USERELATIONSHIP ( Table1[N], Table2[N] )
)

 Besides, why can't you choose Table1[N] to table visual? I think you should provide more detailed information about your actual tables.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.