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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
PBIX_COACH
Helper II
Helper II

Currency conversion totals not correct

Hi All,

 

I'm stuck on this problem where I am able to do the conversion for a single currency however when I try to do a total aggration for the total Sales all converted to CAD I get the incorrect totals. Please see the below screenshot and DAX code. 

 

Any help is greatly appreciated

 

 

Sales Currency (CAD) =
IF (
    ISCROSSFILTERED ('Power BI - NOT' ),
    VAR SelectedCountry =
        SELECTEDVALUE('Power BI - NOT'[Country] )
    VAR DatesExchange =
        SUMMARIZE (
            'FX Exchange Rates',
            'FX Exchange Rates'[MonthYearLong],
            'FX Exchange Rates'[EXRate]
        )
    VAR Result =
            IF (
                SelectedCountry = "USA",
                SUMX (
                    DatesExchange,
                    [Sales Amount] * 'FX Exchange Rates'[EXRate]
                ),[Sales Amount]
            )
       
    RETURN
        Result,
    [Sales Amount]
)

 

PBIX_COACH_1-1698338067653.png

 

 

1 ACCEPTED SOLUTION
EylesIT
Resolver II
Resolver II

@PBIX_COACH,

I've looked at this a bit more, and have another idea. Your measure starts with this IF expression:

 

 

IF(ISCROSSFILTERED ('Power BI - NOT' )...

 

 

I think that when you are not filtering for USD i.e. looking at the whole table unfiltered, then this IF is false, so the ELSE part is executed, which returns [Sales Amount] for every cell. So I think try changing your measure to this:

 

Sales Currency (CAD) = 
    SUMX(
        VALUES('Power BI - NOT'[Country]),
        VAR SelectedCountry = 'Power BI - NOT'[Country]

        VAR DatesExchange =
            SUMMARIZE (
                'FX Exchange Rates',
                'FX Exchange Rates'[MonthYearLong],
                'FX Exchange Rates'[EXRate]
            )

        VAR Result =
            IF (
                SelectedCountry = "USA",
                SUMX (
                    DatesExchange,
                    [Sales Amount] * 'FX Exchange Rates'[EXRate]
                ),
                [Sales Amount]
            )
        
        RETURN Result
    )

 

Note that the your measure only applies currency conversion into CAD when the country is USD. Other countries such as INTL do not have any currency conversion applied. Is this what you intended?

View solution in original post

6 REPLIES 6
EylesIT
Resolver II
Resolver II

@PBIX_COACH,

I've looked at this a bit more, and have another idea. Your measure starts with this IF expression:

 

 

IF(ISCROSSFILTERED ('Power BI - NOT' )...

 

 

I think that when you are not filtering for USD i.e. looking at the whole table unfiltered, then this IF is false, so the ELSE part is executed, which returns [Sales Amount] for every cell. So I think try changing your measure to this:

 

Sales Currency (CAD) = 
    SUMX(
        VALUES('Power BI - NOT'[Country]),
        VAR SelectedCountry = 'Power BI - NOT'[Country]

        VAR DatesExchange =
            SUMMARIZE (
                'FX Exchange Rates',
                'FX Exchange Rates'[MonthYearLong],
                'FX Exchange Rates'[EXRate]
            )

        VAR Result =
            IF (
                SelectedCountry = "USA",
                SUMX (
                    DatesExchange,
                    [Sales Amount] * 'FX Exchange Rates'[EXRate]
                ),
                [Sales Amount]
            )
        
        RETURN Result
    )

 

Note that the your measure only applies currency conversion into CAD when the country is USD. Other countries such as INTL do not have any currency conversion applied. Is this what you intended?

Thanks so much...your formula is working correctly and is giving me the correct output. Also, that is correct it excludes INTL but if in the future I need to include it would I just add a OR clause to include it?

That will depend on how the 'FX Exchange Rates' and your data model is set up.

EylesIT
Resolver II
Resolver II

@PBIX_COACH, I think the problem is that when multiple values exist in the 'Power BI - NOT'[Country] in the filtered context, the measure code returns [Sales Amount] (because SelectedCounty variable is blank, because SELECTEDVALUE('Power BI - NOT'[Country]) is blank).

 

My suggested solution is to change the measure to group the data up by Country, perform the conversion calculation per country into CAD, then sum up the grouped results. So I think you should try changing your measure to this:

 

 

Sales Currency (CAD) =
SUMX(
    VALUES('Power BI - NOT'[Country]),
    IF (
        ISCROSSFILTERED ('Power BI - NOT' ),
        VAR SelectedCountry =
            SELECTEDVALUE('Power BI - NOT'[Country] )
        VAR DatesExchange =
            SUMMARIZE (
                'FX Exchange Rates',
                'FX Exchange Rates'[MonthYearLong],
                'FX Exchange Rates'[EXRate]
            )
        VAR Result =
                IF (
                    SelectedCountry = "USA",
                    SUMX (
                        DatesExchange,
                        [Sales Amount] * 'FX Exchange Rates'[EXRate]
                    ),[Sales Amount]
                )
        
        RETURN
            Result,
        [Sales Amount]
    )
)

 

PBIX_COACH
Helper II
Helper II

No the problem is the total should not be the same because the formula converts the US to CAD which should be higher. if I place the measure in a card it shows the total without the conversion

 

PBIX_COACH_0-1698339310387.png

 

EylesIT
Resolver II
Resolver II

@PBIX_COACH, are you sure this is not just a display format issue? Your Sales Amount column appears to be formatted to zero decimal places, so it will not display the cents. Whereas the Sales Currency (CAD) column does show cents.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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