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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
bsz412
Helper III
Helper III

sales amount calculation by using exchange rate table with historic values

Hi, 

I have to calculate sales amount for multiple countries. The exchange rate table looks like this: 

bsz412_1-1657199460156.png

In the report I have this filter: 

bsz412_2-1657199695036.png

Where the end period is coming from the 'Endperiod' table, as highlighted in yellow.

The request is to calculate local sales amounts to EUR (that column is in the sales_purchase table). The exchange rate should always be the exchange rate of the selected "End Period". So if it is February, all sales, even 2021 Jan should be calculated on FEB 2021 ex rate.

These are my tables: 

bsz412_0-1657199418498.png

I cannot have now a 1 to many relationship between exchange rate and sales_purchase table, so cannot use a simple SUMX and RELATED to calculate everything to EUR. 

Can you please help me how I could do this?

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Try

Sales Amount EUR =
SUMX (
    sales_purchase,
    VAR exchRate =
        LOOKUPVALUE (
            exchange_rate[avg_rate],
            exchange_rate[country_code], sales_purchase[country_code],
            exchange_rate[Year], SELECTEDVALUE ( EndPeriod[Year] ),
            exchange_rate[Month], SELECTEDVALUE ( sales_purchase[Month] )
        )
    RETURN
        sales_purchase[sales_amount] * exchRate
)

View solution in original post

6 REPLIES 6
bsz412
Helper III
Helper III

@johnt75 , I have another page in this report where time selection follows a different logic

bsz412_0-1657213403360.png

here the year slider is coming from the endperiod table year column. When it is filtered like this, the expected output should show Feb-Apr 2022 data. But now as end period table is filtered on 2 years, selectedvalue does not work.... 

is it possible to create a version of the meausre above that gives this expected output?

thanks so much, I really appreciate your help

 

Sales Amount EUR =
SUMX (
    sales_purchase,
    VAR exchRate =
        LOOKUPVALUE (
            exchange_rate[avg_rate],
            exchange_rate[country_code], sales_purchase[country_code],
            exchange_rate[Year], MAX( EndPeriod[Year] ),
            exchange_rate[Month], SELECTEDVALUE ( EndPeriod[Month] )
        )
    RETURN
        sales_purchase[sales_amount] * exchRate

if I just replace selectedvalue to MAX, it will do the job, what do you think?

Yes, that should work

johnt75
Super User
Super User

Try

Sales Amount EUR =
SUMX (
    sales_purchase,
    VAR exchRate =
        LOOKUPVALUE (
            exchange_rate[avg_rate],
            exchange_rate[country_code], sales_purchase[country_code],
            exchange_rate[Year], SELECTEDVALUE ( EndPeriod[Year] ),
            exchange_rate[Month], SELECTEDVALUE ( sales_purchase[Month] )
        )
    RETURN
        sales_purchase[sales_amount] * exchRate
)

OMG it is working, just one tiny correction: 

 

Sales Amount EUR =
SUMX (
    sales_purchase,
    VAR exchRate =
        LOOKUPVALUE (
            exchange_rate[avg_rate],
            exchange_rate[country_code], sales_purchase[country_code],
            exchange_rate[Year], SELECTEDVALUE ( EndPeriod[Year] ),
            exchange_rate[Month], SELECTEDVALUE ( EndPeriod[Month] )
        )
    RETURN
        sales_purchase[sales_amount] * exchRate
)

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.