Dynamically Changing A Chart Axis In Power BI Using Bookmarks And Buttons

A very common requirement when building Power BI reports is to allow the end user to change what is displayed on a chart axis dynamically. A lot of people have blogged about how to do this – Kasper’s blog post here is a great example – but the problem is that all of these solutions involve a lot of work remodelling your data and writing DAX code. However, the good news is that now we have Bookmarks and Buttons in Power BI there’s a new, easy, code-free way of achieving the same result, at least for some chart types. In this post I’ll show you how using the same data that Kasper used in his post.

Say you have the following dataset (using data from the Adventure Works DW sample database) in Power BI Desktop:

image

…and you need to display a column chart that shows the sum of SalesAmount broken down by either Country, Region or Currency.

The first step is to create a column chart and to drag Country, Region and Currency into the Axis well:

image

At this point the column chart will show Country and you’ll have the option to drill down – but don’t drill down yet. Add a Bookmark at this point and call it Country. Do not turn on drill down mode, but click on the “Go to the next level in the hierarchy” button:

image

When you do this, Country will be completely replaced by Region:

image

Add another Bookmark called Region, then click “Go to the next level in the hierarchy” again to show Currency:

image

Add a third and final Bookmark and call this one Currency. At this point you should have three Bookmarks for the three drill states:

image

The last thing to do is to add three buttons to the report linked to the three Bookmarks:

image

In this case I’ve used the “blank” button type, turned on the Outline, added button text that matches the name of the Bookmark, and set the Action Type property to “Bookmark” and then selected the appropriate Bookmark in the Bookmark property. Here’s how my Country button is configured:

image

image

image

image

And that’s it. After the report is published (notice that I’ve also used the new ability to turn off the visual header which makes everything look much tidier) you’ll be able to click the three buttons and switch between viewing Country, Region and Currency like so:

PQSwitchAxis

Of course this only approach works with visuals like the column chart that support drilldown so you can’t use it in all cases, but it does show off how powerful and useful the Button/Bookmark combination is. Ideally the Selection Pane would be able to control the visibility not just of entire visualisations but also of the fields and measures used within a visualisation, which would enable even more scenarios like this.

You can download the sample .pbix file for this post here.

Reordering Multiple Columns With ‘Remove Other Columns’ In The Power Query Editor

In the comments to my last blog post on how the order that you select columns can affect the output of certain calculations, both Bradley Sawler and John B. Thomas pointed out something very useful that I didn’t know about: that the order you select columns can also be used with the ‘Remove Other Columns’ functionality to reorder columns in bulk.

For example, imagine you have a table with columns called A, B, C, D, E and F. If you select the columns in the order F, E, D, A, B and C and the select ‘Remove Other Columns’, the columns are reordered in the order that you clicked them:

PQReorderCols

As you can see from the demo above, ‘Remove Other Columns’ uses the Table.SelectColumns M function behind the scenes and the order the columns are listed in that function is the order that you have clicked them in. A great trick for reordering a large number of columns quickly!

The Order You Select Columns In The Power Query Editor Can Affect The Output Of Some Transformations

Maybe this is obvious to more experienced Power Query users, but something I always point out when I’m training people up on Power Query is that the order that you select columns in the Power Query Editor window (both in Power BI Desktop and Excel) can affect the output of certain transformations. For example, say you have a table with two columns A and B that both contain numbers; if you select A first and then B, and then go to Add Column/Standard/Divide, you’ll get a new column that contains the value of the calculation A/B. However, if you select B first and then A and do the division you’ll get B/A:

PQDivide

The order that you select columns is also significant for some other types of calculation such as Percent Of and Power, and also when you do a Merge Columns.

The Binary.InferContentType M Function

The April 2018 release of Power BI Desktop included a new M function: Binary.InferContentType. There’s no online documentation for it yet but the built-in documentation is quite helpful:

image

I tested it out by pointing it at the following simple CSV file:

image

…and with the following M code:

let
    Source = File.Contents("C:\01 JanuarySales.csv"),
    Test = Binary.InferContentType(Source)
in
    Test

Got the following output:

image

It has successfully detected that it’s looking at a CSV file; the table in the lower half of the screenshot above is the table returned by the Csv.PotentialDelimiters field, and that shows that with a comma as a delimiter three columns can be found (my recent blog post on Csv.Document might also provide some useful context here).

I also pointed it at a few other file types such as JSON and XML and it successfully returned the correct MIME type, but interestingly when I changed the file extension of my JSON file to .txt it thought the file was a text/CSV file, so I guess it’s not that smart yet. I also could not get it to return the Csv.PotentialPositions field mentioned in the documentation for fixed width files so it may still be a work in progress…?

Make Excel Reports Created With Analyze In Excel Work After Publishing To Power BI!

I think Power BI’s a great tool, but like most Power BI users I have a list of my own pet features that I would like to see implemented to make Power BI even greater. What I would most like to see addressed is the fact that, right now, Analyze In Excel only works with Excel on the desktop but not after you have published a workbook to Power BI. It seems crazy to me (and it’s very hard to explain to customers too) that Analyze In Excel lets you create reports in Excel using PivotTables and cube functions connected to a Power BI dataset, but when you publish your report to a Power BI workspace – so that the Excel workbook and the source data are both in Power BI – the reports stop working because Excel Online cannot connect back to Power BI.

There has been a post on the Power BI Ideas forum about this for some time, but recently I was talking to some guys from the Excel dev team and they told me that it’s actually something they, not the Power BI team, need to address. Therefore I created a post on the Excel UserVoice forum too:

https://excel.uservoice.com/forums/274580-excel-online/suggestions/33793252-pivottables-created-with-power-bi-using-analyze-in

Please vote for it! The more votes it gets, the more likely it is to be implemented quickly. Ken Puls managed to get a lot of votes for his idea to improve Power Query performance, and since that’s now in the process of being implemented it just goes to show that voting does influence what the Excel dev team works on.

Why is this important? In my opinion, Power BI is not a good ad-hoc data exploration tool and isn’t intended to be – its strengths lie elsewhere. However people do want to explore data stored in Power BI and an Excel PivotTable is the ideal way to do this (the Power BI matrix visual is very limited in comparison), and after you have found something interesting it’s only natural that you should want to share it. PivotTables aren’t the only thing Excel has to offer though: I’m a big fan of cube functions too, especially for creating financial reports, and Power BI has nothing remotely like them. Finally, don’t forget all those people who want to build reports in Excel because it’s Excel and that’s what they know. All in all getting this feature implemented would be a major boost for Power BI and broaden its range of capabilities.

BI Survey 18

It’s that time again: the BI Survey (the world’s largest survey of BI tools and users) needs your input. Here’s the link to take part:

https://www.efs-survey.com/uc/BARC_GmbH/396b/?a=101

As a reward for participating you’ll get a summary of the results and be entered into a draw for some Amazon vouchers. As a reward for plugging the BI Survey here I get to see the full results and blog about them later on in the year, and the results are always fascinating. Last year Power BI was breathing down the necks of more established vendors like Tableau and Qlik; this year I expect Power BI to be in an even stronger position.

Power BI Roadmap Announcements In the Dynamics 365 Spring ‘18 Release Notes

There have been a lot of important Power Apps and Flow announcements today, as well as the announcement about the Common Data Service for Analytics which is undoubtedly massive news for Power BI users, but buried in the very large “Dynamics 365 Spring ‘18 Release Notes” pdf file (downloadable from https://aka.ms/businessappsreleasenotes) are a number of equally significant revelations about the Power BI roadmap for the next few months. I’ve summarised them here, along with the relevant page numbers; I’ve also highlighted what I think are the most important ones.

  • (P177) Control over linguistic schema – it looks like the phrasing and synonyms functionality for Q&A that was in the old Power BI service has been added back
  • (P178) User experiences for Q&A in reports – report authors will be able to allow report consumers (I assume people who have had reports shared with them via Apps) to use Q&A, as well as to provide suggested questions
  • (P178) Incremental refresh policies – the first sighting of incremental refresh in Power BI! But as the screenshot shows, this is for Premium only (which is not a surprise). It looks like it will be a lot easier to use than managing incremental refresh using partitions in SSAS.
    image
  • (P185) Performance reporting for Power BI Premium – seems to be more detailed metrics for Power BI usage and performance
  • (P186) Data source setup improvements – better UI for configuring datasets and links to gateways
    image
  • (P186) Query acceleration for large datasets – this will allow you to create DirectQuery datasets but then create some in-memory aggregate tables to improve query performance
  • (P186) Power BI metadata translations – translations like we have in SSAS Tabular today, I guess, allowing table and column names to be translated and users to see these translations when they connect
  • (P187) Smart alerts – seemingly an improvement on the existing alert functionality, with some extra AI thrown in?
  • (P187) Slideshow mode – cycle through pages in a report when the report is in full-screen mode
  • (P187) Workspaces with Azure AD Groups – workspaces are being separated from O365 Groups (at last!) and instead permissions can be controlled using Azure AD security groups or Office 365 modern groups
  • (P188) Report Snapshots for Power BI Premium – more subscription options for Premium users
  • (P188) SSRS Reports in Power BI Premium – run SSRS reports inside Premium, with no separate installation of SSRS required. Azure Reporting Services has been resurrected!?
    image
  • (P188) Subscribe other users for email subscriptions – at last!
  • (P189) XMLA connectivity for Power BI Premium – connect to Premium workspaces as if they were Analysis Services instances (which they pretty much are, I guess)
  • (P189 and P209) Common Data Services for Analytics capability in Power BI – Iots more detail on this new service in this section than is available in the post on the Power BI blog linked to above
  • (P192) Power BI Insight apps – pre-built Power BI solutions for services like Dynamics 365 and Salesforce
  • (P194) Details on the roadmap for Power BI Embedded
  • (P204) Details on the roadmap for the Power BI Mobile apps

Not in this document, but mentioned in this blog post today is the fact that the web-based version of Power Query that can be used to load data into the Common Data Service is out of Preview.

All I can say is wow – there’s so much to take in here, and it seems like the pace of innovation is only getting faster. It’s also nice to see Microsoft publishing a comprehensive roadmap document like this: it’s something many of my customers have wanted for a long time, and really helps them with their planning.