Switching currency in Power BI
In one of my recent Power BI projects I stumbled upon the need to switch currencies between SEK and EUR. The company mainly looks at SEK, as their head quarters are in Sweden but it is a global company and many times the number crunchers that dive into the reports are only interested in EUR. Sure I could build 2 separate reports and put myself in the situation where I need to make all the adjustments twice when changes are requested or I could add a slicer to the report with which you can decide if the numbers are in SEK or EUR. There are probably a couple of different ways you can do this, but this is how I made it work! Feel free to copy as you like.
The Dataset
For my sample I have created 2 tables in an Excel file. You can download this if you want at the end of the post.
I have a transaction log on the left where every transaction is in SEK. On the right I have a Currency rate table that show the average rate for 1 EUR in SEK by that month. It stretches from 2010 until 2020, the same as the transaction log.
Prepping the data
I just imported both tables above as they are but I’ve added a third manual table from a blank query in Power BI. This is named “Currency Selector” and has only one column named Currency. In here I have 2 values; SEK and EUR.
Moving over to the Transactions table, I’ve created a new column for the Currency period. This gives me the first day of every month so that it looks like the date column of the currency rate.
Currency period = Transactions[Date].[Year]&"-"&Transactions[Date].[MonthNo]&"-01"
I’ve added a second column with every transactional row in EUR, translated from my currency rate table.
Sum in EUR = Var ExchangeRate = LOOKUPVALUE('Currency'[Average Rate],'Currency'[Date],Transactions[Currency period])ReturnTransactions[Sum] / ExchangeRate
This column looks up the value in the currency rate table based on the period of the transactional row. It then divides the SUM that is in SEK with the rate to EUR. We now have every transaction in both SEK and EUR! What we need now is the ability to change it on the fly in the report. Time to go back to that Currency Selector table that we’ve created and also create a measure!
I’ve made a measure called Cost. This summaries the SEK or the EUR column depending on if you have filtered the Currency Selector table.
Cost = Var SelectedCurrency = CALCULATE(COUNTROWS(CurrencySelector),FILTER(CurrencySelector,CurrencySelector[Currency]="SEK"))
Return
IF(SelectedCurrency= 1, // Value if True. We use the SEK column SUM(Transactions[Sum]),
// Value if false. We use the EUR column SUM(Transactions[Sum in EUR]))
Now you just have to drag and drop the measure Cost to your visualizations and add a slicer to your report so that you can select either EUR or SEK. I would suggest make the slicer Single Select so that you couldn’t make the mistake of selecting both currencies.
My slicer is in the left upper corner and this is the view based on SEK or EUR selected from it.
That’s all there is to it folks! Feel free to download the sample data if you want to try it out!
Cheers!
Hello are using WordPress for your blog platform?
I’m new to the blog world but I’m trying to get started and create
my own. Do you need any html coding knowledge to make your own blog?
Any help would be greatly appreciated! https://vanzari-parbrize.ro/parbrize/parbrize-man.html
Great that you’re getting started with blogging! I’m using wordpress for Cloudapt and no, you don’t need to know about any HTML or other coding what so ever. You can just write in building blocks and paste images right into the web browser!
It’s very trouble-free to find out any matter on net as compared
to textbooks, as I found this piece of writing
at this site.
I’m truly enjoying the design and layout of your blog. It’s a very easy on the eyes which makes it much more pleasant for me to come here and visit more often. Did you hire out a designer to create your theme? Excellent work!
Thanks!
No I built it myself using white background on each visualization and enabled the shadow. The colors are made using a custom theme with the Altitude 365 colors.
https://docs.microsoft.com/en-us/power-bi/create-reports/desktop-report-themes
I got what you mean , thanks for putting up.Woh I am happy to find this website through google.
Can I put some of this on my page if I include a link to this website?
Sure thing!
It’s genuinely very difficult in this busy life to
listen news on TV, thus I simply use web for that reason, and take the most up-to-date information.
It’s amazing for me to have a site, which is beneficial designed for my know-how.
thanks admin
I really enjoy this theme you have got going on on your site. What is the name of the template by the way? I was thinking of using this style for the website I am going to put together for my school project.
Hi there just wanted to give you a brief heads up and let
you know a few of the images aren’t loading properly.
I’m not sure why but I think its a linking issue. I’ve tried it in two different web browsers and both show the same results.
Is it okay to post some of this on my page if I post a reference to this page?
Every weekend i used to pay a quick visit this web page,
as i want enjoyment, for the reason that this
this website conations genuinely good funny material too.
I’m not sure where you are getting your information, but good
topic. I needs to spend some time learning more
or understanding more. Thanks for wonderful info I was looking for this info for my mission.
Tyvm for the helpful post! I would not have gotten this myself!
Not a unhealthy post, did it take you numerous of time to consider it?
First of all I would like to say superb blog! I had a quick question that I’d like to ask if you do not mind.
I was interested to know how you center yourself and clear your head before writing.
I have had a tough time clearing my mind in getting my thoughts out.
I truly do enjoy writing however it just seems like the first 10
to 15 minutes are generally wasted simply just trying to figure out how to begin. Any
recommendations or tips? Thank you!
Great line up. We will be linking to this great article on our site. Keep up the good writing.
Hi to every one, for the reason that I am genuinely keen of reading this web
site’s post to be updated on a regular basis.
It consists of pleasant information.
Heya i’m for the first time here. I found this board and I find It really useful& it helped me out a lot. I hope to give something back and help otherslike you helped me.
Hi! I found your blog on Google.Its really comprehensive and it helped me a lot.
Hey, thanks for the post.Much thanks again. Great.