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
JRossA
Regular Visitor

Cumulative Total multiple currency conversion using current rate for balance each period

This is what I'm trying to achieve:
Using current exchange rate for balances (aka. Running Totals, Cumulative Total) in periods that may not have entries. 

 

Basic example: 

Exchange Rates: USD->GBP

January: 0.75

February: 0.76

March: 0.8

 

I deposit 1000 USD in my back account in January worth 750 GBP (1000 * 0.75). No further entries. 

End of March the account balance is still 1000 USD but it's now worth 800 GBP (1000 * 0.80) based on latest exchange rate.

In my attempts with DAX I keep getting the balance to: 750 GBP rather than 800 GBP. 

 

My real life scenario involves an enterprise that owns multiple businesses across the world with different functional currencies and needs to provide consolidated financial statements (income statements & balance sheets). 

So we have a transaction currency and reporting currency.

My test data model is identical to Kasper's example: https://www.kasperonbi.com/currency-conversion-in-dax-for-power-bi-and-ssas/

Except I have a DimDate table instead of "ExchangeDate" and I've replaced his "FactSales" with a "General Ledger" alongside new dummy data. 

image.png

I have 3 measures:

TrnExchangeRate = 
VAR selectedCurrency = SELECTEDVALUE(ReportingCurrency[CurrencyCode];"USD")
RETURN
CALCULATE(Min(ExchangeRates[ExchangeRate]);FILTER(ExchangeRates;ExchangeRates[ReportCurrency]=selectedCurrency)) 

PostingAmount = SUMX('General Ledger'; [PostingAmount_LCY] * [TrnExchangeRate]) 

PostingAmount Balance = 
IF (
    MIN ( 'Calendar'[Date] )
        <= CALCULATE ( MAX ( 'General Ledger'[PostingDate] ); ALL ('General Ledger' ) );
    CALCULATE (
        [PostingAmount];
        FILTER (
            ALL ( 'Calendar'[Date] );
            'Calendar'[Date] <= MAX ( 'Calendar'[Date] )
        )
    )
)

Above DAX provides the correct currency conversion for entries. But balances reflects the exchange rate based on the PostingDate and not the current date in filter context.

 

In below example I've hard-coded exchange rates of: 3, 4 and 5 for Oct, Nov and Dec respectively. 

In the first table you can see, the "PostingAmount" is converting the amounts correctly for entries.

In the second table, I'm filtering on "Cash On Hand", and you can see the balance is 300 (100 * 3) for November and December whereas I wanted that to be 400 (100 * 4) and 500 (100 * 5).image.png

I hope above is sufficient details to assist me? This is my first post. I couldn't seem to upload the PBIX file with my dummy example.

Thanks!

1 ACCEPTED SOLUTION
JRossA
Regular Visitor

This ended up supplying the solution:

 

I combined the data model from: https://www.kasperonbi.com/currency-conversion-in-dax-for-power-bi-and-ssas/

 

With the measure definition from accepted solution: https://community.powerbi.com/t5/Desktop/Running-Total-multiple-currency-conversion-to-one/m-p/14099...

 

Thank you for your assistance @v-chuncz-msft 

View solution in original post

2 REPLIES 2
JRossA
Regular Visitor

This ended up supplying the solution:

 

I combined the data model from: https://www.kasperonbi.com/currency-conversion-in-dax-for-power-bi-and-ssas/

 

With the measure definition from accepted solution: https://community.powerbi.com/t5/Desktop/Running-Total-multiple-currency-conversion-to-one/m-p/14099...

 

Thank you for your assistance @v-chuncz-msft 

v-chuncz-msft
Community Support
Community Support

@JRossA 

 

You may check if the post below helps.

https://community.powerbi.com/t5/Desktop/Find-last-value-based-on-date/m-p/293150#M129228

Community Support Team _ Sam Zha
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.