Power BI Premium has supported metadata translations – translations for table, column and measure names etc – for a while now. Kasper has a great blog showing how to use this feature here; Tabular Editor makes it very easy to edit metadata translations too. However (unlike SSAS Multidimensional) Power BI doesn’t have native support for data translations, that’s to say translating the data inside your tables and not just the names of objects. There are some blog posts out there that describe ways of tackling this problem but none are really satisfying or reliable: techniques involving row-level security, for example, can force you to use relationships in a way that will impact performance; the undocumented UserCulture() DAX function isn’t ready and shouldn’t be used in production yet. In this blog post I’m going to describe a new approach to solving the problem of data translations that relies on the DirectQuery on Live connections functionality released in preview in December. It is far from perfect but I think it’s the best way of solving this problem available at the moment.
Describing the problem
The best way to understand the problem and what this new approach offers is to look at the end result. Here’s a Power BI report where everything is in English:
And here is exactly the same report where the same information is shown translated into German (apologies for the actual translations…):
There are several things to point out in this German version of the report:
- The text in the title at the top and in the sidebar is now in German
- The column headers for the matrix are now in German (this is what has been possible for a while with metadata translations)
- The dates are now formatted using the default for the German locale (again, as a result of metadata translations)
- The day names are now shown in German. This is the key thing here – the data in a column, as well as the metadata has been translated
- The decimal values in the Umsatz column are now formatted using the German locale so that a comma is used as the decimal separator and a full stop (ie a period for my American readers) is used as a thousands separator (again, as a result of metadata translations)
- The text indicating the total row is now in German (this is the normal behaviour of Power BI for users with a German browser locale)
So how do you get both data and metadata translations working in Power BI? Here’s a super-simple example showing how…
Step 1: The source dataset
First, let’s take a look at the dataset that contains all the data for both these reports. It contains two tables.
The Sales table looks like this:
Note that the Day Name column contains the names of the days of the week, and that there are two other columns containing the names of the days of the week translated to German and French. This is the table that holds the data shown in the matrix in the reports above.
There is also a table called Text that contains the text shown in the title and sidebar in the reports above. Again, there is a column containing the English text and two other columns containing German and French translations of that text:
There are no relationships between these tables:
Finally, this dataset also needs to be published to a workspace in the Power BI Service.
Step 2: Building the English version of the report
Building the original English version of the report is also quite straightforward. The matrix just contains data from the Sales table:
The only interesting thing is how the text in the title and sidebar is handled. In both cases I have used a card visual and dragged the Text column from the Text table into it, then filtered the data on the Visual column of the Text table so the appropriate text is shown:
In this case the sidebar shows the data from the Text column (aggregated to get the First value) where the Visual field contains the value “Textbox”.
Step 3: Creating the German translation dataset
This is where things get interesting. The next thing to do is to open a new .pbix file in Power BI Desktop, create a Live connection to the dataset created in step 1, and then hit the “Make changes to this model” button to create a new local dataset. This is where the new DirectQuery on Live connections functionality comes in; you should read the documentation on this feature before you go any further. The important thing to remember is that when you do this you are not duplicating any data or logic that is in the original dataset but you can make your own modifications to it.
There are two things that have to be done in this dataset. First, in Power BI Desktop, some renaming is necessary:
- The “Day Name” column on the Sales table has been renamed “English Day Name”
- The “German Day Name” column on the Sales table has been renamed “Day Name”
- The “Text” column on the Text table has been renamed “English Text”
- The “German Text” column on the Text table has been renamed “Text”
This results in the following columns in the local dataset:
Second, a translation object needs to be added to the dataset for the German (de-DE) locale for the metadata translations. I used Tabular Editor (instructions here) because it was the quickest and easiest way to add metada translations:
Note how the name of the Sales table has been translated to Umsatz, and how the names of the Date, Day Name (note: this is the column that has just been renamed as Day Name, which points to the German Day Name column in the original dataset) and Sales columns have been translated to Datum, Tagesname and Umsatz respectively.
This local dataset also needs to be published to the Power BI Service to proceed.
Step 4: building the German version of the report
The last thing to do is to go back to the original English version of the report built in step 2, open it in Power BI Desktop, then point it to the new German local dataset created in the previous step. You can do this by going to the Home tab in the ribbon, clicking on the Transform data button and then selecting Data source settings:
…and then selecting the German local dataset like so:
At this point you’ll see that the report is in a semi-translated state: the data has been translated but the metadata has not been.
Don’t panic though! Metadata translations can only be viewed in the browser or by changing the language settings inside Power BI Desktop so this is to be expected.
Notice that the middle column in the matrix points to a column called ‘Sales'[Day Name]. In the source dataset this contains the English day names; in the German translation dataset we have switched the names of the columns so ‘Sales'[Day Name] now contains the German day names. This is the key to solving the problem: all you need to do is ensure that each of the translation datasets you create exposes the set of table, column and measure names that your report expects; you just need to rename columns appropriately in each translation dataset so that they point to the columns in the source dataset that contain the correct translated names.
You should then save the .pbix file and publish again. You’ll either need to change the name of the report or publish it to a separate workspace; I recommend the latter, because it means you can tell all your German-speaking users to go to one workspace for their reports and your English-speaking users to go to another for their reports.
And that’s it – someone with a German browser locale viewing the version of the report connected to the German translation dataset will see this:
Here’s a diagram showing everything that has been built so far:
English-language users (who will have an English-language browser locale) use the original report that points to the source dataset. German-language users (who will have a German-language browser locale) use the German version of the report, which in turn connects to the German translation dataset; this gives them the German data and metadata translations.
The important things to remember are:
- Even though you have multiple datasets there is no duplication of data or logic because of the way the new DirectQuery on Live connections functionality works.
- Even though you have multiple copies of the same report for different languages, the report design in each case is identical and the only the dataset that each report points to is different.
As a result the effort needed to maintain multiple translated copies of the same report is kept to a minimum.
Not too far in the future there will be new and improved functionality in Power BI that makes solving this problem even easier, and at that point I’ll write a follow-up blog post.