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
harizothman
Frequent Visitor

How to get values from 2 different columns based on a different criteria?

Hello everyone,

 

I would like to create a table where it shows a total value for a different criteria.

For example, my data looks like this;

 

Country NameOriginal CurrencyOriginal Currency AmountConverted Currency to  GBP
AmericaUSD                                     1,000.00                                                    -  
GermanyEUR                                     2,000.00                                       1,829.61
FranceEUR                                     1,500.00                                       1,372.21


My plan is to show a finalized table that looks like this;

 

NameReport Amount
America                   1,000.00
Germany                   1,829.61
France                   1,372.21

 

Please note that, for America, I want to show the original currency amount which is in USD 1,000.

For the other two, I want to show the converted currency to GBP.

 

I only know a way = CALCULATE(SUM(Original Currency), Original Currency="USD") but this will only show America.

Is there any other work around for this?

 

Thank you.

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

Hi @harizothman ,

 

You can use @FarhanAhmed 's method, the measure is this.

Report Amount1 = 
IF (
    MAX ( 'Table'[Country Name] ) = "America",
    SUM ( 'Table'[Original Currency Amount] ),
    SUM ( 'Table'[Converted Currency to  GBP] )
)

 

Or you can use SWITCH function to create a measure.

Report Amount2 = 
VAR OCA =
    SUM ( 'Table'[Original Currency Amount] )
VAR GBP =
    SUM ( 'Table'[Converted Currency to  GBP] )
RETURN
    SWITCH (
        MAX ( 'Table'[Country Name] ),
        "America", OCA,
        "France", GBP,
        "Germany", GBP
    )

 

The result is this.

10.png

 

 

You can check more details from here.

 

 

Best Regards,

Stephen Tao

 

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-stephen-msft
Community Support
Community Support

Hi @harizothman ,

 

You can use @FarhanAhmed 's method, the measure is this.

Report Amount1 = 
IF (
    MAX ( 'Table'[Country Name] ) = "America",
    SUM ( 'Table'[Original Currency Amount] ),
    SUM ( 'Table'[Converted Currency to  GBP] )
)

 

Or you can use SWITCH function to create a measure.

Report Amount2 = 
VAR OCA =
    SUM ( 'Table'[Original Currency Amount] )
VAR GBP =
    SUM ( 'Table'[Converted Currency to  GBP] )
RETURN
    SWITCH (
        MAX ( 'Table'[Country Name] ),
        "America", OCA,
        "France", GBP,
        "Germany", GBP
    )

 

The result is this.

10.png

 

 

You can check more details from here.

 

 

Best Regards,

Stephen Tao

 

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

hi @FarhanAhmed and @v-stephen-msft ,

 

yes, the solutions provided answered my queries.

 

thanks for the help!

FarhanAhmed
Community Champion
Community Champion

 

 

= IF ( Original Currency="USD" , SUM(Original Currency), SUM(Converted Currency))

OR

= IF ( Country="America" , SUM(Original Currency), SUM(Converted Currency))







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




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.