Franco Arda, Frankfurt am Main (Germany)                                                                                                                 franco.arda@hotmail.com

Search
  • Franco Arda

How to add currency rates to Tableau Dashboards using Python?

Currency conversion allows the Tableau user to change results based on foreign exchange rates. For example, let's say you have sales in Australian Dollars. By using the free exchange rate library Forex Python, currency conversions are updated automatically based on exchange rates based by the European Central Bank.


Tamas Foldi posted a similar idea on "Add live currency conversion to Tableau Dashboards using TabPy." For some developers, he's approach is more straightforward as he calls the Forex Python directly from Tableau's Calculated Field. Where I strongly disagree with him is displaying the currency exchanges. Without explicitly stating the cross rate, a used is very likely to be confused.

Note that you need to run TabPy in order to automated updated currency conversions possible. As many Data Scientists favorite IDE, I'm using here Jupyter Notebook to connect to taby_client and locally run it (localhost:9004).

Yes, that's more complicated then "only" using Tableau's Calculated Field to call Forex Python. The problem, or better challenges for developers like me is, that I need to be used to it. For more advanced models, I always have to write a Python function first. One example is a Machine Learning algorithm. Indeed, I've seen many developers calling Machine Learning algorithms directly from Tableau's Calculated Field. But that's highly risky. I would never do it. In futures posts, you'll see how I approach writing a Machine Learning algorithm first in Python and then call the prediction with Tableau.

Let's focus on currency conversions at hand. Forex Python is a Free Foreign exchange rates and currency conversion (e.g. USD to EUR). With the following Tableau Parameter I can control the currency conversion. Note that I explicitly state the currency cross conversion (e.g. 1 USD is 0.7690 GBP) to avoid confusion.

My slightly different Calculated Field requires two arguments, one for the column (e.g. Sales) and one for the cross currency conversion.

Again, this approach requires to use tabpy.query which I use to call my written function.

Here's a Tableau Dashboard which incorporates the Currency Conversion Parameter. One tricky challenge is to modify the currency prefix in each pane.

Conclusion: As often, if you use the Tableau Dashboard only once, then adding a Python script is a most likely going to be an overkill. We're probably much faster just writing a short function in Tableau and hard coding the cross currencies. But, if you need a Tableau Dashboard regularly with updated cross currencies, this approach makes sense.


Let's imagine you need to update the cross currency exchanges daily. That takes you easily one hour to find the rates, update them and check if they are correct. Daily one hour is around 20 hours a month. So this approach can save you easily 200 hours per year.


9 views