Power BI Slicers

For those coming from the Excel 2013 world, you’ll surely want to create filters using the Power BI Slicers.  After all, you know that Slicers and Timelines are two of the sexiest filters we have for controlling filter context in Power Pivot models.  In this post we’re going to explore the slicer visual, and how to get closer to what you’re used to in Excel.

The Goal

I’m going to fall back to my last project here, and have created a single visual on a blank report page.  You probably remember this one, it’s the map of where I’ve stayed so far this year:


What I’d like to do now is add my slicers and timelines.  I’d like a slicers for Country and Province.  Should be easy, no?  Err… no.  Sad smile

The default Power BI Slicers

Now, Power BI Desktop has a Slicer visualization, as you can see here:


So what’s wrong with it?  I’ll build two to show you why I’m less than satisfied…  Here’s what I did:

  • Created a Slicer visual
  • Added the Country field
  • Created another Slicer visual
  • Added the Province field

Do these look like Excel slicers to you?  They look a lot more like check boxes to me, not slicers…


Now don’t get me wrong, Power BI Slicers certainly work, as you can see here where I’ve drilled in to USA:


So let’s look at the difference between the Power BI Slicers and the Excel slicers that my expectations are based upon:

  • The Province field hides all irrelevant items by default, unlike Excel.  I could not find a configuration option to change this.
  • The checkbox thing drives me crazy.  I hate checkboxes in my Windows files list, I don’t like them here, and again it is inconsistent with Excel.  I could not find a way to turn those off.
  • Originally I wanted to show the provinces in a two column slicer, like I can in Excel.  I could not figure out how to make this happen either.
  • Finally, I wanted to show the bubbles like an Excel slicer.  The closest I could get was the image below (WARNING! SUPER UGLY GRAPHIC AHEAD!)  Should you feel the need to create this abomination you need to select the slicer, go to the Formatting roller –> Items –> Outline –> Frame.


Gross.  That is just gross.  Honestly, I really don’t understand why the slicer is so different from Excel’s.  That slicer is pretty, and people are used to it.

Not happy with these, I deleted both slicers.

Is all hope lost for attractive Power BI Slicers?

Thankfully, the answer is no.  The Power BI team has given developers the ability to create and distribute their own visuals into the Power BI custom visuals gallery.  So let’s go and pull in a couple of those to fill this gap.

Locating the Custom Visuals Gallery

To be fair, the steps for this could be MUCH easier.  To get here the first time you can either just click this link or follow these steps:

  • Click the ellipses in the Visualizations gallery to import a custom visualization


  • Choose to Import a Custom Visual
  • Click the Learn More link


  • To be fair, you should probably read the page you’re taken to, as it talks about all the risks of using a custom visual.  (Remember not all custom visuals are provided by Microsoft, many are provided by 3rd parties.)
  • I scrolled straight to the bottom and clicked the link in the See Also section to go to the Power BI custom visuals gallery

You’ll be taken to the gallery, which has a lot of pretty visuals that can be imported into your project.

To make it easier to find custom visuals, I’d recommend you do a couple of things here:

  1. Bookmark this page (making it a bit easier to get back to it.)
  2. Choose to sort the gallery by Name rather than by Most Recent (which is the default)

When you click on a visual it will offer to download a pbiviz file that you can store in a folder.  You’ll want to remember the location, as you’ll need to import the visuals into every new PBI file you create.

I downloaded a specific visual here: the Chiclet Slicer which, ironically, is published by Microsoft.

Importing the Chiclet Slicer

When I returned to Power BI desktop, it’s still sitting at the Import Custom Visual dialog, which is convenient.  So I was able to just click the big yellow Import button, and select the ChicletSlicer file.  Doing so adds a new option to the Visualizations gallery:


I created two new Chiclet slicers, one for Country and one for Province, and was pleased to end up with the following:


Now that’s more like it!  Certainly needs some tweaking, but better than the past iteration.  So let’s get to that tweaking…  I changed the formatting options for each of the slicers as follows:

  • The Country slicer
    • General –> Columns –> 1
    • Header –> Off
    • Chiclets
      • Unselected Color = very light grey
    • Title –> On
      • Text = Country, Font Color = Black, Alignment = Center, Text Size = 10
  • The Province slicer
    • General –> Columns –> 2
    • Header –> Off
    • Chiclets
      • Unselected Color = very light grey
    • Title –> On
      • Text = Country, Font Color = Black, Alignment = Center, Text Size = 10

And, as you can see, the results are pretty good:


A couple of things that I couldn’t figure out here though:

  • I wanted to align the text in my “chiclets” to the left, like in Excel.  Can’t seem to find an option for that.
  • There is a tantalizing option in the “General” section to show disabled items “Inplace”, and an option in the chiclets to set the colour for those items.  I would have expected it to be equivalent to Excel’s “Show Disabled”, but it doesn’t seem to do that.  I have not figured out how to replicate that effect.

Final Thoughts

To be fair, there are a ton of configuration options for the Chiclet slicer, much more than I’m going to cover.  Why this slicer isn’t part of Power BI’s default install is beyond me… especially since it’s published by Microsoft.

Values Become Text After UnPivoting Other Columns

Have you ever set up a nice query to UnPivot other columns, only to find that the query data types change when you add new columns?  This post will cover why values become text after unpivoting other columns.


We’ve got a nice little table called “Data” showing here.  Nothing special, it just summarizes sales by region by month, and our goal is to unpivot this so that we can use it in future Pivot Tables.  (You can download the source file here.)


Now, you will notice that April’s sales are outside the table. This is by design, and we’ll pull it in to the table later when we want to break things.  Smile

UnPivoting Other Columns – The Hopeful Start

If you’ve been following my blog for any period of time, you’ve seen this, but let’s quickly go over how to unpivot this:

  • Select a cell in the table
  • Go to Power Query (or Data in Excel 2016) –> From Table

We’re now looking at the Power Query preview of the table:


Great, now to unpivot…

  • Hold down the Shift key and select the Country and Prov/State column
  • Right click the header of either of the selected columns and choose Unpivot Other Columns
  • Right click the headers of the two new columns and rename them as follows:
    • Attribute –> Month
    • Value –> Sales

Re-Pivoting from the Data Model

With the table complete, I’m going to load this to the data model and create a Pivot Table:

  • Go to Home –> Close & Load –> Close & Load To…
  • Choose to Load to the Data Model

The steps to create the Pivot depend on your version of Excel:

  • Excel 2013: Go in to Power Pivot –> Home –> PivotTable and choose a location to create it
  • Excel 2016: Click any blank cell and go to Insert –> PivotTable.  As you have no data source selected, it will default to using the data model as your source:


With the PivotTable created, I’ve configured it as follows:

  • Rows:  Country, Prov/State
  • Columns:  Month
  • Values:  Sales

And that gives me a nice Pivot like this:


Let’s Break This…

Okay, so all is good so far, what’s the issue?  Now we’re going to break things.  To do that, we’re going to go back to our original data table and expand the range:


In the picture above, I’ve left clicked and dragged the tiny little widget in the bottom right corner of the table to the right.  The table frame is expanding, and when I let go the Apr column turns blue, indicating that it is now in the boundaries of the table.

With that done, I’m going to right click and refresh my Pivot Table, leaving me with this:


Huh?  Why was the sales measure removed?  And if I drag it back to the table, I get a COUNT, not a SUM of the values?  And even worse, when I try and flip it back to SUM, I’m told that you can’t?  What the heck is going on here?


Importance of Power Query Step Order

To cut to the chase, the issue here is that when we first created the table in the data model, the Sales column was passed as values.  But when we updated the data to include the new column, then Sales column was then passed entirely as text, not values.  Naturally, Power Pivot freaks out when you ask for the SUM of textual columns.

The big question though, is why.  So let’s look back at our query.

Our original data set

If we edit our query, we see that the steps look like this:


To review this quickly, here’s what happened originally

  • Source is the connection that streams in the source data with the following columns:


  • Changed Type set the data type for all the columns.  In this case the Country and Prov/State fields were set to text, and the Jan, Feb & Mar columns were set to whole number.  We can see this by looking at the icons in the header:


Note that if you don’t have these icons, you should download a newer version of Power Query, as this feature is available to you and is SUPER handy


  • We then selected the Country and Prov/State columns and chose to Unpivot Other Columns.  Doing so returned a table with the following headers


Notice that the first three columns are all textual, but Sales is showing a numeric format?  Interestingly, it’s showing a decimal format now, but it shows the numeric format because all unpivoted columns had explicitly defined numeric formats already.

The final steps we did was to rename our columns and load to the data model, but the data types have been defined, so they were sent to the data model with Sales being a numeric type.

Why Values Become Text After UnPivoting Other Columns

Okay, so now that we know what happened, let’s look at what we get when we step through the updated data set.

  • First we pulled in all the columns.  We can plainly see that we have the new Apr column:


  • The Changed Type step is then applied:


Hmm… do you see that last data type?  Something is off here…

So when we originally created this query, Power Query helpfully pulled in the data and applied data types to all the existing columns.  The problem here is two-fold:  First, the Apr column didn’t exist at the time.  The second problem is that Power Query’s M language uses hard coded names when it sets the data types.  The end effect is that upon refresh, only the original columns have data types defined, leaving the new columns with a data type of “any” (or undefined if you prefer).

  • We then unpivoted the data, but now we see a difference in the output


Check out that Value column.  Previously this was a decimal number, now it’s an “any” data type.  Why?  Because there were multiple data types across the columns to be unpvioted, so Power Query doesn’t know which was the correct one.  If one was legitimately text and Power Query forced a numeric format on it you’d get errors, so they err on the side of caution here.  The problem is that this has a serious effect on the end load to Power Pivot…

  • Finally, we renamed the last two columns… which works nicely, but it doesn’t change the data type:


Okay, so who cares, right?  There is still a number in the “any” format, so what gives?

What you get here depends on where you load your data.  If you load it to the Excel worksheet, these will all be interpreted as values.  But Power Pivot is a totally different case.  Power Pivot defaults any column defined as “any” to a Text data type, resulting in the problems we’ve already seen.

Fixing the Issue

For as long as we’ve been teaching our Power Query Workshop, we’ve advocated defining data types as the last step you should do in your query, and this is exactly the reason why.  In fact, you don’t even need to define your data types in the mid point of this one, that’s just Power Query trying to be helpful.  To fix this query, here’s what I would recommend doing:

  • Delete the existing Changed Type step
  • Select the final step in the query (Renamed Columns)
  • Set the data type for each column to Text except the Sales column, which should be Decimal Number (or currency if you prefer)


When this is re-loaded to the Data Model, you’ll again be able to get the values showing on the Pivot Table as Sum of Sales.

Avoiding the Issue

Now, if you don’t want Power Query automatically choosing data types for you, there is a setting to toggle this.  The only problem is that it is controlled at a Workbook level, not at a global Excel level.  So if you don’t mind setting it for every new workbook, you can do so under the Power Query settings:


Is Changed Type Designed in the Correct Way?

It’s a tough call to figure out the best way to handle this.  Should the data types be automatically hard coded each time you add a new column?  If the UnPivot command had injected a Changed Type step automatically, we wouldn’t have seen this issue happen.  On the other hand, if a textual value did creep in there, we’d get an error, which would show up as a blank value when loaded to Power Pivot.  Maybe that’s fine in this case, but I can certainly see where that might not be desirable.

Personally, I’d prefer to get a prompt when leaving a query if my final step wasn’t defining data types.  Something along the lines of “We noticed your final step doesn’t declare data types.  Would you like me to do this for you now (recommended)” or something similar.  I do see this as an alternate to the up-front data type declaration, but to be honest, I think it would be a more logical place.

October News and Events

It’s a busy month here at Excelguru. Instead of a technical post we wanted to catch everyone up on our October news and events!

Live Course: Master Your Excel Data October News and Events

Ken is teaching a LIVE, hands on course in Victoria, BC on Friday, October 21 from 9:00am-4:30pm. This session is great for anyone who has to import and clean up data in Excel and will change the way you work with data forever! Ken will teach you how to use Excel Tables, Pivot Tables and Power Query. Space is limited to only 20 attendees, so don't miss out on your chance to sign up. For full details and to register for the session, visit: http://www.excelguru.ca/content.php?291-Live-Course-Master-Your-Excel-Data.

October News and Events: Power BI Meet-up

The next Vancouver Power BI User Group meet-up is happening on Thursday, October 13 from 5:30-7:00pm. Scott Stauffer, Microsoft Data Platform MVP, will be presenting on How to Operationalize Power BI. Together we’ll look at some solutions that might help pass your Power BI solution over to IT to manage enterprise-wide. Dinner and soft drinks will be provided. View the full details and sign up to attend at: http://www.meetup.com/Vancouver-Power-BI-User-Group/events/234126999/.

Microsoft MVP Award Received

For the 11th straight year, Ken has received the 2016 Most Valuable Professional Award from Microsoft! The previous 10 years, Ken’s award has been in the Excel category, but this year’s award is in the Data Platform category. The new category reflects the work he’s been doing this past year with Power Query and Power BI. Congratulations Ken, your guru status remains assured.mvp_horizontal_fullcolor

Our Team Has Grown

As we mentioned the other day, Rebekah Sax has recently joined the Excelguru team. She brings with her a wealth of experience in marketing, communications, event planning and administration. Please join us in welcoming Rebekah as she helps us make new connections and continue to grow.

New team member

I’m pretty stoked to announce a big milestone for Excelguru.  That’s right, we’ve added a new team member to our company!

We’re pleased to announce that Rebekah Sax has joined our team and will be helping us with our marketing efforts.  She spent the last 15 years working at Fairwinds in a variety of roles from marketing to event planning (and more), and her broad skill set is just what we needed in order to fill some pretty big gaps in our practices. In fact, you can already see the effect.  If you remember the Excel Courses Calendar I set up on my website ages ago… it’s actually got courses listed now!

Sharing Power BI Reports (for External Users)

This is the fourth installment of this post series, and will demonstrate the process for publishing and sharing Power BI Reports.  Key things we’ll look at here are how to publish the dashboard, keep it up to date, and share it with users outside our company.  (We will look at sharing with internal users the next post.)

Series Table of Contents

This is a portion of a series of blog posts, which build on each other to create an overall solution from Data to a Power BI dashboard.  You’ll want to follow along in order, so here’s the table of contents for the series:

Subscription Levels

In order to make this whole solution work, I’m assuming the following:

  • The person publishing the dashboard has a Power BI Pro subscription.  This is needed to enable the feature to schedule refresh.
  • All other internal users have a Power BI Free subscription… because I’m cheap like that. Smile
  • External users may or may not have a Power BI subscription at all.

So basically, to sum this up really quick, if you only have one person authoring and publishing your dashboards in your company, you only need one Power BI Pro license, and the rest of your team can be on the free version.

The good news is that it’s totally free to sign up for Power BI, you just need a “work” email.  (I.e. it won’t let you sign up with your hotmail, gmail, or yahoo address, but if it’s some kind of custom domain, you should be fine.)  In fact, you can most likely even sign up even if your IT department hasn’t yet.  If you want to try it, head over to the Power BI site.

Publishing the Report to Power BI

The first thing we need before we can start sharing our reports is publish them.  Doing that is simple once we have our account set up.  We start by going to Power BI Desktop and opening our Power BI Desktop file.

Now, if you haven’t signed in to Power BI, you’ll want to do that first:

  • Go to File –> Sign In
  • Enter the email and credentials to your Power BI account and commit them

Once you have successfully logged in, that will make things easier, as it won’t prompt you when you’re publishing.  So assuming you’ve done this, you can now:

  • Go to File –> Publish –> Publish to Power BI.

Because my company uses Office 365 Unified Groups, I actually get a long list of locations where I can publish my report, but I’m going to choose the very top one call “My Workspace”.  (You may not have or get any groups, but everyone has a the My Workspace area.)

A few seconds later I’m given a happy little message about how it was successful:


And that’s it for Power BI Desktop.  You can click the link or dismiss the message and log in at http://powerbi.microsoft.com.  No matter which, you can shut down Power BI Desktop and move to your web browser.

Exploring the Power BI Interface

On the left, you’ll see that you’ve got a few areas that you can navigate into, as shown below (yours may be expanded, I collapsed them for easier reading):


The important pieces for us here are the Reports and Datasets areas of the navigation pane.  The data for our file is separated from our report, so we need to talk to both portions.  But first, I’m just going to take a look at the report in the Power BI web interface.  To do that II :

  • Selected reports on the left (only required if it is collapsed)
  • Selected the Hotel Stays report

And, as you can see, I’ve got a nice report that looks just like it did in Power BI desktop.  It even cross filters the same:


So this is kind of cool.  It’s no longer on my PC, it’s stored in the cloud, as is the data set.  So in theory, I could update my Excel file with a new hotel, and it should refresh since that file is stored in my OneDrive for Business, right?

Sorry, but not yet.  See the Refresh button the red arrow is pointing at?  That will refresh the report from the data set (although I believe you need to refresh the data set first).  So manual, so let’s fix that first.

Keeping the Reports up to date with Scheduled Refresh

Again, in order to set up scheduled refresh of our reports, we must have a Power BI Pro subscription.  If you don’t… well… you can still use the solution, but you’ll need to come in and manually click the button to refresh it (and seriously, who wants to do that?)  I’m going to assume you do have a Power BI pro subscription, and we’ll carry on here.

So to set this up, I clicked on the Datasets button in the navigation window on the left, then selected the Hotel Stays data set.  That took me to a blank page that has a very Power BI Desktop like experience, including a Refresh button in the top right:


This area can be used to manually force the data set to update, and can even be used to build additional reports.  But neither is what we want.  What we need is a way to schedule the refresh, which is found by clicking the … icon beside the data set name:


Clicking Shedule Refresh takes me to a page and – after about a 1 second delay – gives me some other important info:


Okay, so I need to confirm my password.  I’m not going to cover this in much detail, as Chris Webb recently covered this part in detail.  I will point out that OneDrive for Business is, in fact, SharePoint (just in case you’re wondering why we see a reference to SharePoint there.)  So all we need to do is click the Edit Credentials link and re-login to the Office 365 account.  Just make sure you change it from Anonymous to oAuth2 before trying to sign in.


Once done, you can expand the Schedule Refresh area, flip the flag to Yes, and you should be good to go:


A few of key points to be aware of here:

  1. Sometimes Power BI seems to forget that it has been authorized.  You may need to come back in and re-login.  That’s only happened to me once so far, but I’ve seen people mention that it happens to them more frequently.
  2. The above is why that last checkbox is SUPER IMPORTANT.  Microsoft will email you whenever a scheduled refresh fails, so that you are aware and can fix it.  This is huge, and I’d recommend you leave that box checked.
  3. You can add more frequent refreshes although – in my experience – you’re limited to about 10 times per day.  I really don’t need more than daily here, but for other dashboards I’ve set them to refresh every 2 hours during business hours.

At any rate, with this set, we click Apply and forget about manual until Microsoft emails us to let us know something stopped working.

Sharing Power BI Reports Externally

Now, the data is being kept up to date, and now we want to share the report with others externally.  How?

  • Click Reports and drill into the report you want (Hotel Stays for me)
  • On the report, go to File –> Publish to Web


  • Click Create Embed Code then Publish

This will give you a nice dialog that provides two things:


Here’s a direct link to the email-able URL, which you can see renders nicely in the online app.

And here is what happens when you embed the iframe in your site.  (Yes, it’s fully clickable!)

So that’s pretty cool and pretty easy.  The only caveat (which works fine for me for my purposes) is that this is 100% public.  While the end audience can’t see any of the underlying data, anyone on the internet who gets this url can see and play with the dashboard.

Final Thoughts

So this is a pretty cool thing so far.  We’ve got a solution where the data set can be access from OneDrive for Business via the Excel app on my phone.  I can add new records there and they are saved, then automatically refreshed in the Power BI report that lives in my Office 365 tenant.  And better yet, I have been able to publish a fully interactive report to the web that will update over time and that you can click and drill into.  Neat stuff for a pretty low cost.

But I know what you’re thinking… you’re thinking that this is all great, but what if we want to share it with users INSIDE the company, and we don’t want to just publish it as a public facing page.  Well hang tight, because that is the focus of the next post in the series.

Creating Power BI Card Visuals

In this post I’m going to continue the process of creating a Power BI dashboard built off the data I sourced from OneDrive for Business.  This time I’m going to look specifically at creating Power BI Card Visuals.

Series Table of Contents

This is a portion of a series of blog posts, which build on each other to create an overall solution from Data to a Power BI dashboard.  You’ll want to follow along in order, so here’s the table of contents for the series:

Today’s Goals – Adding Power BI Card Visuals and another Chart

Let’s just circle back on the wireframe I presented in my last post:


I’ve already made the Map and the Stays by Country chart.  Now I need to add my Key Stats and the Stays by Hotel Brand chart.

Showing Key Stats with Power BI Card Visuals

Ultimately, what I want to show on my dashboard is some key indicators that filter as I select other visuals on the dashboard.  Something that looks like this, which is reacting to my filtering to only stays in Canada:


Creating DAX Measures for my Power BI Card Visuals

So the first thing I want to do is think about the data that I want to display.  I’m tracking nights away from home, which I call (Hotel) “Stays”.  There’s 3 main measures that I’m after:

  • Stays (Selected): This is base measure which was created in the last post in the series.
  • Stays (All): This value should always show the total nights I’ve been away from home.
  • Stays (YTD): This value should show the total nights I’ve been away from home for the current year only.

As a reminder, the Stays (Selected) measure was defined as:

Stays (Selected) = COUNTROWS(Stays)

Creating the next two measures is just as easy as the previous one.  To do this I selected the Modeling tab –> New Measure, and created the following measure formulas:

Stays (All) = CALCULATE(Stays[Stays (Selected)],ALL(Stays))

Stays (YTD) = CALCULATE(Stays[Stays (All)],Year(Stays[Date])=Year(TODAY()))

Each was set with a whole number format with commas and zero decimal places:


Now, to be fair, you don’t have to set up all your DAX measures up front.  You can (and I frequently do) create DAX measures as you need them.  I had already visualized what I wanted, so knew I’d need these ones.

Multi-Row Power BI Card Visuals or Single Cards?

So now that I have my DAX measures built, I’m want to get these into the cards.  My first instinct was to grab a multi-row Power BI card visual and just check all 3 measures.  The problem is that it gives me this:


Now, I can get rid of the bar on the left (Formatting –> Card –> Show Bar = off), and I can change the size of the values (Formatting –> Data Labels –> Text Size).  What I can’t do, however, is centre the values over the text like I can with individual cards.  (At least not as of the latest build of Power BI Desktop.)  It’s always the little things that get me, but it looks like we’re going to need to go to individual cards for what I want.

Creating my Power BI Card Visuals

Creating 3 visuals instead of one is a little bit painful, but certainly do-able.  Here’s how I did it.

  • I went to the Visualizations gallery –> Card
  • Then went to Fields –> Stays (Selected)


Which gave me this:


Perfect.  So then I just created the other two.  The hardest part, honestly, was lining them up.  Rather than dragging and drop I set the properties manually, as I could then ensure that my card heights and widths and top position were identical.  I then only hard to play around with the X position for each card.  (You can find this menu by selecting the card, then clicking the format icon (under the visualizations gallery).  Once you’ve done this, expand the General section.


One thing that does bug me about this is that as soon as you select the next visual, the General section will collapse on you again.  I really wish it stayed expanded, as it would make it much easier to quickly compare values.

Regardless, I ended up with the visuals I wanted and they react properly when I click Canada in my Country column chart:


Or Australia:


Creating the Stays by Hotel Brand chart

With the key stats done, we can now focus on creating a Power BI Bar Chart to show the Stays by Hotel Brand.  There’s no major secret to this one, in fact it’s even easier than the column chart I created in the last post, only because it doesn’t have any drill down levels.  Here’s what I did to create this one.

  • I started by clicking on the blank canvas (to clear selections so I don’t accidentally turn a card into a chart!)
  • I went to the Visualizations gallery and selected the top left icon for the Bar Chart
  • I checked Hotel Brand – automatically adding it to the Axis
  • I checked Stays (Selected) – automatically adding it to the Values area


That seemed pretty easy so far, but it could use some tweaking.  So I clicked the formatting roller and made a few more adjustments to it:

  • X-Axis = Off
  • Data Labels = On
  • Title
    • Title Text = Nights Away From Home by Hotel Brand
    • Font color = Black
    • Alignment = Centre
    • Text Size = 12 pt

And then I resized the chart to show the full width of the hotel brand names.


There are a couple of options I’d love to see here that don’t exist today, mainly revolving around the Y axis.

  1. While I have the option to show the axis on the right side, I don’t have any ability to align the text to the left.  Personally I can’t stand the fact that the text is not aligned with every word started at the same horizontal position.  It’s just weird.
  2. In order to show all the text, I have to expand the entire chart, making it super wide.  Why?  Because I don’t have the ability to set the axis width independently, nor do I have the ability to control the font size for the axis.

At any rate, it looks pretty good for my purposes right now, and I’m sure the font size and alignment (if not the axis column width) will be added in future.

Most importantly, we can see that by filtering my Nights Away from Home chart, it still cross filters this chart.  The view below shows just how brand loyal I’m not when filtered to Canada:


Final Thoughts

With a couple of additional text boxes added to the page, my dashboard development is complete, returning something that I can easily cross filter and explore:


Note that I started this post a while ago, so the data has a few more nights in this version of the screenshot.

In the next post I’ll look at publishing this to Power BI, creating an interactive view for the public, and schedule the refresh to keep it up to date.

Creating Power BI Visuals

Last week I grabbed some data from OneDrive for Business.  This week I’m going to start the process of creating Power BI visuals to build a dashboard which will be hosted in the cloud.

Series Table of Contents

This is a portion of a series of blog posts, which build on each other to create an overall solution from Data to a Power BI dashboard.  You’ll want to follow along in order, so here’s the table of contents for the series:

  • Get Data From OneDrive for Business
  • Creating Power BI Visuals (this post)
  • Creating Power BI Card Visuals (forthcoming)
  • Sharing Power BI Reports (forthcoming)
  • Sharign Power BI Dashboards (forthcoming)

Dashboard Wireframe

My friend Jon Peltier exposed me to the concept of creating a wireframe for a dashboard, which is essentially a quick design layout.  (It’s more complicated than that, but for my purpose I know my key stats, so am looking at the layout now.)  So here’s the draft of what and how I want to place my visuals:


Now, I’m not going to build all of this in this one post.  (I’m only going to build the left side in this post.)

A little DAX – Creating a measure for Selected Stays

Before we get too deep into this, we need to quickly talk about about the key metric is that we want to display in the dashboard visuals.  All maps and charts show key values of some kind, in my case I’d like that to be the number of nights that I’ve been away from my home.  As I mainly stay in hotels when I’m away, I’m going to call the measure “Stays (Selected)”.  (The reason for the “Selected” component will become clear in the next post.)

To create this measure, I needed to go to the Modeling tab and choose New Measure.  In Power BI Desktop, you provide both the measure name in the formula bar, as well as the actual measure itself.  So here’s what I went with:

Stays (Selected) = COUNTROWS(Stays)

The measure name comes first, followed by the = character.  (In Power Pivot for Excel, we’d see := instead.) The measure itself uses the same DAX formula as we would in Excel, which is a simple count of all unfiltered rows remaining in the table.  This is good, as it will allow my reports to cross filter based on selections made in other visuals.

The final thing I did after creating the measure was to tweak the formatting a little bit.  I set it to Whole Number, ensuring that it had 0 decimal places and used a comma format (for when my hotel nights creep over 1,000!)


Power BI Visuals – Map

With the DAX measure built, I’m ready to finally start using my data.  And I really want to start with something visual, so I’m going to start with the map.

There are two Power BI visuals for maps in Power BI Desktop; the map and the filled map.  I’m going to use the first one.  So here’s exactly what I did:

  • I clicked the Power BI Visual for Map
  • I selected the Full Address field
  • I selected the Stays (Selected) field
  • I wondered why nothing showed up on my map

Oh yes, this was a serious WTF moment, honestly.  Here’s what I saw (with arrows added to prove out the mapping):


I recreated this map twice and added other visuals before I figured out what was going on here… as it happens, my data was actually too wide for the default map size.  Look what happens when I widen the map:


So Power BI team, if you’re reading this, the default size of the map is just plain wrong.  Give us one that shows the entire world!

At any rate, now that this I know my data is actually there, I can clean up the chart by giving it a better title.  To do that I:

  • Selected the map visual
  • Clicked the format icon under the Visualizations gallery (now looks like a little paint roller)
  • Expanded the Title field
  • Change the Title Text to:  Nights Away From Home by Location
  • Changed the Font color to black
  • Changed the Alignment to Center
  • Set the Text Size to 12

And the result is as follows:


Power BI Visuals – A Basic Column Chart

With the map done, it’s now time to move on to the next Power BI Visual: a column chart.

To create this, I did the following:

  • Clicked the blank canvas outside my map.  (I can’t tell you how many times I’ve pressed CTRL+Z to undo changing a visual from one type to another!)
  • Clicked the Column Chart (second icon in the Visualizations gallery)
  • Selected Country from the fields list
  • Selected Stays (Selected) from the fields list

Not only do I get my cool chart, but clicking on one the countries drills in to all the stays I’ve had, and zooms in the map as well.  No extra connections or configuration needed.  In this image I’ve drilled in to USA, and you can see that I worked my way down the Oregon coast this summer, as well as the stays I had in the Seattle and San Jose areas for conferences:


Using the chart is pretty easy at this stage: just click a bar.  Click a different bar and it cross filters to those selections, click the same bar again and it un-filters.  Hold down your CTRL key as you’re making selections and you can even get multiple countries like this view of Canada and USA:


As cool as that is, I’d still like to customize the chart a little.  To do so, I selected the chart and clicked the formatting icon below the visualization gallery again.  The changes I made were:

  • Y-Axis
    • Off
  • Data Labels
    • On
    • All other options left as defaults
  • Title
    • Title Text: Nights Away From Home by Region (Drillable)
    • Font Color: Black
    • Alignment: Centre
    • Text Size: 12

So when all is complete, it looks like this:


To me that is much cleaner.

(Note that according to my wireframe, the column chart will live under the map.  I’m only leaving it next to the map for now to make better use of space in the blog post.)

Power BI Visuals – A Drillable Column Chart

So the column chart is cool and all, but I wanted to be able to use it to drill down into a finer level of detail, like Province/State.  Unfortunately just typing that in the title won’t do it, we need to make a change.

So far everything I’ve built has just worked nicely.  I’ve been able to single click everything, and it’s just gone right into the correct place.  But when I click the Province field in the Fields pane, I get this disaster:


This plainly is not what I want!

The issue here is that Power BI Desktop makes the assumption that the Province field should move to the Legend.  We need to move it to slide into the Axis, just below country.  As you drag it, you’ll see a solid yellow line snap in just under the Country field:


And when you let it go, your chart looks like it’s reverted to what you had before.. but there is a difference.  Near the top of the chart, we see a few new icons:


And here’s what they do:

  • The first (currently shaded) icon is “drill out” to go back up one level.  (It’s shaded, as I’m at the top level)
  • The second (with the double down arrows) drills in to the maximum level.  This would show nonsense data for me, as it shows every Province/State in all countries, without their parent country.
  • The third icon (single down arrow) is a toggle to turn on/off drill down mode.  It’s a bit awkward, as you’ll see, but is very effective for my purposes.
  • The funky little square near the end just sends your chart into full screen mode.

So let’s take a look at my USA stays.

We’ve already seen above what happens if I click the bar for USA; it filters both the map and the chart.  So let’s drill in.  I click the single down arrow on the right, then click USA.  My data re-plots as shown below, and the single down arrow turns black to show it is in drill down mode:


So this tells me that so far I’ve spent the same amount of nights in California, Oregon and Washington.  (That was actually a surprise, but fair enough.)  What’s odd to me here though, is that it removes all filters from the map.  I personally don’t think that this should be the case if I’ve selected something then click the drill in arrow.

So now I want to drill in to just Oregon.  So I click the OR bar, and nothing happens.  And this is exactly what I meant when I said it’s a bit awkward.  If you had more levels below this (maybe a city field), you’d drill in there.  If you want to filter the chart to just Oregon, you need to click the down arrow again to clear drill down mode, so that you can go back into filter mode.

So after clicking the black arrow, we can then select the Oregon bar:


Or Washington:


To get back to BC, I need to drill up to get back to my Country selection.  I can do that by clicking the up arrow in the top left.  That will take me back to the Country choice.

Now, based on what I’ve said earlier, you’d expect that you would need to do the following to drill into BC:

  • Click the Drill Down arrow
  • Click on Canada
  • Click the Drill Down arrow again to clear it
  • Click BC

And that’s EXACTLY what you’d have to do if you were using a touch screen to consume your dashboard.  For PC users (which you probably are as the author), you also have this option.

From the Country view

  • Leave the Drill Down arrow un-selected
  • Right click the Canada bar –> Drill Down
  • Left click BC

And it works the same as the touch version with 2 less clicks:


For the record, Drill Up works the same way when you are in a drill down level, as you can see here:


Final Thoughts

At this point, I’m going to slide the column chart down under my map, as per my original wire frame.

I should probably also mention here that you’re not stuck to only one level of drill down.  If your data is properly hierarchical and has multiple levels, add them to the axis.  It can make for a pretty powerful experience when a user is able to keep drilling in.

My only complaint with this feature is really around the un-filtering of other visuals in the report when I drill in.  Personally, I think the other visuals should be filtered to that level.  (I.e. if I drill in to USA, I shouldn’t be seeing Australian cities in my map until I click a State name.)

Next post will focus on building the cards, as well as the final chart.

Get Data From OneDrive for Business

It’s been a few weeks since I’ve posted a technical blog post, and I need to get back to it, so here goes.  This is going to be a two part post on how to Get Data From OneDrive for Business, (using Power Query,) which will allow us to create a dashboard that reads from an Excel file hosted in the cloud.  In addition, as a bit of a departure for me, I’m going to demo this using Power BI Desktop, although connecting to the data this way will work with Excel as well (creating the visuals would of course be different.)

In this installment I’ll show how to get data from OneDrive for Business.  Next week I’ll show how I created some visuals, published it to a public facing web page, and how I set up the scheduled refresh to keep it up to date.

Architecture Background

Before we get into how to connect to the data, let’s just talk about where the data lives and why I decided to architect the solution using the route I did.

Folder Setup

Some time in the past, I went and connected to my OneDrive for Business folder, synching it to my laptop.  This allows me to create Excel files locally to store my data, but have them available in the cloud as well, and even access and update them via Excel on my iPhone.


Obviously I don’t have a ton of folders in my OneDrive for Business folder, but the key one I’m after is a file called Hotel Stays.xlsx which resides in the Hotel Stays folder.  This is the file that I use to track the number of nights I’m not sleeping in my own bed.  As I travel a lot now, I figured that this might be interesting to track.

Excel File Setup

The structure of the Excel file is fairly simple.  It has a single table in it (called “Stays”), and I update it with a record for each day that I’m away from home:


I think this is pretty straight forward, the only nuances here are:

  • Every hotel night is logged as a new line
  • There are independent columns for the street address, city, province and country

So the cool thing here is that I can log updates from my PC or via my phone to keep this up to date.  As I don’t capture a ton of info it’s actually pretty quick to do.

Other Architecture Decisions

Now I could have just connected to the Excel file locally, but I really want to host this as a report and schedule refreshes in the Power BI service.  To do that, I can’t really read from the local copy of the file, as that would require me to configure a personal data gateway and also to ensure that my PC is always on.  As I travel with my laptop I can’t guarantee that so – to allow scheduled refresh without errors – the data needs to read from the cloud hosted version.

So basically, what I want to build is an architecture that looks like this:


Get Data From OneDrive for Business

So let’s get started on this, and see where it takes us...

What Connection Do We Use?

As it turns out, in order to connect to an Excel file that is stored in a OneDrive for Business folder, we actually need to connect to a SharePoint folder and drill into the Excel file we want.  It’s kind of like using the classic From File –> From Folder method, only targeted at a web hosted link.

The only problem is… what address do you throw in there if you’re working from your OneDrive for Business folder?

I’ll admit that this wasn’t the most intuitive to figure out.  To work it out, here’s what I did:


This helpfully takes me to a new page that shows all my files in the web browser.  As it happens, the URL for this page also contains the information I need in order to be able to connect to the SharePoint folder using Power Query technology.


The URL we need is to be constructed as follows:

  • https://TenantName-my.sharepoint.com/personal/UserEmailAddress/

So, as you can see, my Tenant Name is xlguru and the email address has both the @ and . replaced with underscores.  This is kind of an important thing to realize here… the Tenant Name is not the same as your domain name.  This gets chosen when the Office 365 account is created, and you can register several domains against it.  (I have 4 domains associated with my xlguru tenant.)  So if you aren’t the admin, the steps above may be the easiest way to work out what it is.

Connecting to a SharePoint Folder

Now that we know the URL we need, it’s time to connect to the folder.  I got started by creating a new Power BI Desktop project.

In the past we didn’t have a way through the user interface to provide the necessary connection, so we had to write the M code manually.  Fortunately we’ve now got a connector to do this for us, it’s the Get Data –> More… –>File –> SharePoint Folder command (in Excel it’s New Query –> File –> SharePoint Folder).


NOTE:  If you don’t have this icon in your list, it means that you are on an older version of Power BI Desktop/Power Query in Excel.  If you’ve updated to the latest version and you still don’t have it, it’s a bug that will be fixed.  You can still do it, you’ll just need to create a blank query and paste in the M code I’ll show you in a bit.

I then pasted the URL to my OneDrive for Business into the URL.

Of course, you’ll then be prompted to sign in.  To do this you’ll want to sign in under Organizational Account and provide your Office 365 credentials.


Successful completion will take you to the preview window where you can just click “Edit”:


Quick side question here… does anyone find this dialog is actually useful?  I can’t think of a single time that I haven’t clicked Edit to do more work with it, so it’s basically just a pretty way to slow me down.

If You Don’t Have the SharePoint Folder Option

If you don’t have the SharePoint folder connector for some reason, you can get to the same place by doing the following:

  • Create a new Blank query
  • Go to the Advanced Editor
  • Replace the Source line with:

Source = SharePoint.Files("https://TenantName-my.sharepoint.com/personal/UserEmailAddress/", [ApiVersion = 15])

This will get you a full list of all the files in your OneDrive for Business folder.

 Accessing The Data

Now that we’re connected to the OneDrive for Business folder, we can get to the data we want.  In my case, I want to dig into the Hotel Stays file and retrieve the data from the Stays table.  To do that I now just treat it like any Excel file:

  • Locate the correct file
  • Click the “Binary” of the file to expand it


  • Drill into the Stays table


End result is that I’ve managed to land some nice data that I can use for my visuals:


There is a small manipulation I do want to make to my data before I call this done though.  I’ll need a “Full Address” field in order to plot things on a map visual.  To get that I:

  • Selected the Address, City, Province & Country fields
  • Went to Add Column –> Merge Columns
  • I chose to use a 2 character separator of “, “ (comma + space)
  • I called the column “Full Address”

And finally I named the table “Stays” and clicked Close & Apply.

Checking Our Progress

Okay, so looking back on what has been accomplished so far, I’ve managed to:

  • Create an Excel file with my data
  • Save the file in a local folder that syncs into my OneDrive for Business folder
  • Create a Power Query that reads from the web hosted (not the local copy) of that file

This is the groundwork I’ll need in order to create a solution where I can enable auto refresh of the dashboard and publish it publicly… which I’ll discuss next week.  Until then, hopefully this has been helpful to understand how to connect to a OneDrive for Business hosted file.

Opportunity: Influence Excel Charting Features

Hi everyone, I’ve got a quick message/opportunity for you from the Excel team.  In their words:

This survey is being conducted by the Microsoft Excel team. In the future, new charting features will be added to Excel. We want to better understand how you expect charts, that have new features, to be displayed and behave in older versions of Excel that don't have these new features.

This survey will take approximately 10 minutes. Feedback from this survey will be used to improve the user experience in Excel. Responses to this survey will not be associated with any personal information.  Please see the Microsoft Privacy Statement for further privacy details on all Microsoft products.

Thank you for participating,

Excel Team

Click to Start Survey

Fix: Excel Formulas don’t update in Power Query tables

If you’re new to Power Query, chances are you’re more comfortable doing tricky mathematics using Excel formulas, rather that Power Query formulas.  No shame there, but you’ve probably run into a situation where you set up the formulas, refresh your query and the Excel formulas don’t update in Power Query 's output table.

I’ve worked with this issue for a long time, and it’s actually caused me to avoid using Excel formulas in tables generated via Power Query all together. Having said that, there is now an easy way to fix this which renders that avoidance obsolete.

The Issue:  Excel Formulas don't update in Power Query tables

Let’s take a quick look at this scenario.  We have a simple table called Animals as follows:


And it gets landed in another table.  But in this table, we added a new column called “Est” to the end, which holds the following formula: =[@Price]*[@Quantity]


So far so good, but what happens when we add a new line to our Animals table and refresh it?


Plainly, this is not good at all!

The Fix:  Excel Formulas don't update in Power Query tables

The fix is remarkably simple, once you know what to do:

Step 1: Change the Table Design Properties

  • Select any cell in the OUTPUT table (the green one)
  • Go to Table Tools –> Design –> Properties (External Table Data group)


  • Check the box next to Preserve column soft/filter/layout and click OK


Now, at this point, nothing appears to change.  In fact, even refreshing the table seems to make no difference.

Step 2: Ensure the Formulas are consistent

The reason the formulas didn’t fill correctly for us is different now.  It is entirely based on the fact the formula in the last column is no longer consistent.  Naturally, that means that Excel won’t auto-fill the formula, as it doesn’t know which is correct (the formulas or the blank cell.)  We need to fix that before this will work for us.

  • Copy from the first formula cell down the entire column (I've got reports that this DOES matter, and that copying from another cell may not fix it.)

Our data should now look something like this:


Step 3:  Test it

And now, when we add new data and refresh the Power Query…


Wrap-up Thoughts

On my Excel 2016 this behavior is now default.  I don’t know when it changed, to be honest.  And if your behavior is different, I’d love to know.  I’m running the Office Pro Plus subscription – first release.

On Excel 2010/2013, the old default of not updating the tables appears to prevail.  It’s actually for this reason that I covered this, as it came up as a question in my Power Query forum.

I’m not sure if this is good or bad, but this setting can/must be managed for each output table individually.  There doesn’t seem to be a way to set one behavior or other to apply to all tables.  To be honest, I think they’ve got it right in Excel 2016, so at least it’s fixed if you’re current.  (And for reference, my understanding is that this required a patch to Excel, not Power Query, which is why I suspect that we likely won’t see it fixed for Excel 2010/2013.)