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

DAX - Selected slicer/value and row in data column are same, then give a certain output

Hi all,

 

I'm very new to Dax and I'm building a model in PowerPivot (which I will use in PowerBi when finished).

 

I have a financial report where I'm converting multiple currencies to one reporting currency which is selected by a slicer. It is set up as in the following link:

https://www.kasperonbi.com/currency-conversion-in-dax-for-power-bi-and-ssas/

 

I have an Exchange Rate table set up. However for each day I am missing the currency rate where the "From currency" is the same as the "to currency" => So where my Exchange rate needs to be 1.

 

I thought of adding lines into my table but this would mean adding thousands of lines for multiple currencies on multiple dates.

 

I thought of creating a dax formula where I can say => If the row in the facts table (can be any currency) is the same the reported (selected with slicer) currency, then I want the amount in the row to be multiplied by 1. Otherwise I want the row to be multiplied by the actual exchange rate.  (see a pivot example below where the issue occurs when EUR to EUR is reported)

 

My current measures are like this :

 

TrnExchangeRate=MIN('Dim Exchange rates'[Exch. Rate])

This will get the lowest factor value from the fact table.

 

Now to calculate the sales per transaction I will use SUMX to achieve this:

TotalSales = =IF(HASONEVALUE(ReportCurrency[ReportCurrency]);SUMX('Fact PL Data';'Fact PL Data'[Amount in local currency]*[TrnExchangeRate]))

 

However if my currency in PL DATA is "EUR" for example, and my reporting currency is also "EUR", then I currently get a blank value. Because I never have 1 as an exchange rate in my table.

 

What would be the easiest dax formula to solve this?

 

Or would you recommend me adding all these in the exchange rate table for each day? 

 

1.PNG

2 REPLIES 2
Anonymous
Not applicable

I was googling around in the meantime and thought I could do it like this:

 

=if(ISBLANK('Dim Exchange rates'[Min of Exch. Rate]);1;MIN('Dim Exchange rates'[Exch. Rate]))

 

But I think this is not best practice. Because if I will have some dates where I actually do not have any exchange rate data between different currencies, then I will probably get 1 as an exchange rate, instead of an actual blank...

 

 

Anonymous
Not applicable

With this comes another issue

=> I checked my Exchange rate data and I am actually missing exchange rates for some transactions => 

 

For example CZK to CHF currency I do not have any rates for some dates. 

 

Could there be an easy workaround for this? Like taking the average of a previous period instead of having a blank calculation? Or going from CZK to EUR and then finding the EUR/CHF rate? But my Dax knowledge is super limited so no idea how to set this up....

 

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.

Top Solution Authors