We use Power BI quite a bit nowadays to help customers visualize their data. Power BI is a great because it simplifies the querying and presentation of business data using dynamic and interactive visualizations. It’s relatively user friendly with drag and drop functionality and supports many different data sources such as SharePoint, Excel, SQL and many others.
One thing that we have seen cause confusion with Power BI (and its counterpart in Excel, Power Query) is how to handle multi-value fields where the data is stored in a single field as a delimited value. We see this quite a bit with SharePoint Choice and Lookup columns that allow multiple selections. You will also see the same behavior with Project Server and Project Online Enterprise Custom Fields (ECFs) that use a Lookup Table and allow multiple selections.
If you want to report on this data and use it as a Slicer and/or to get discrete counts from it, it’s not always intuitive on how to handle it in Power BI or Power Query.
Let’s walk through an example using a SharePoint list and Power BI.
First, let’s create a SharePoint Custom List called Training Requests.
- In your SharePoint site, click on New > List
- In Name, enter Training Requests
- Click on Add column and select Number
- In Name, enter # of Students
- Click on Save
- Click on Add column and select Choice
- In Name, enter Training Topic
- For Choices, enter the following:
- Power BI
- PowerApps
- Flow
- SharePoint
- Power BI
- Click on Save
- Click on Add column and select Choice
- In Name, enter Locations
- In Description, enter At which locations should the training be conducted?
- For Choices, enter the following:
- Boston
- New York
- Philadelphia
- Washington DC
- Pittsburgh
- Raleigh
- Charlotte
- Atlanta
- Boston
- Click on More options
- Change Allow multiple selections to Yes
- Click on Save
Now that we have our Training Requests list created, let’s populate the list with sample data. Create 15-20 items with a variety of locations and # students. When finished, your data should look something like this:
Note how the Locations column is storing the data – it’s a multi-value field showing a comma delimited list.
Now let’s move to Power BI and see how it sees this data.
- Open Power BI Desktop
- First we need to query the data from our SharePoint list. To do this, on the Ribbon click on Get Data > More… > Online Services > SharePoint Online List > Connect
- In Site URL, enter the URL to your SharePoint site and click on OK
- If prompted for credentials, click on Microsoft Account > Sign In and login with your Office 365 account.
- Click on Connect
- In the Navigator screen, select the Training Requests list and click on Edit
- We don’t need all of the list columns, so on the Ribbon click on Choose Columns > Choose Columns. Uncheck (Select All Columns) and check the following: Id, Title, # of Students, Locations, Training Topic
- Note that Locations shows as a List and not the actual values. For now, let’s click on the Locations expand icon
and choose Extract Values. Choose Comma for the delimiter. Click on OK
- Click on OK then Close and Apply
- On your Power BI canvas, add a Table.
- In the Fields pane, select all 5 fields for Training Requests
- You may have to resize your table to see all the data. Your Power BI canvas should look like this:
- Let’s add a Slicer and select Locations
- Note how the Slicer and the Table are showing the locations as a single text string. If you click on a value in the Slicer, it will filter on an exact match of that string, not each discrete location.
- As you can see, Extract Values doesn’t give you the desired result if you want to find each discrete location. Let’s fix this so we get the results we want.
- On the Ribbon, click on Edit Queries > Edit Queries
- Let’s create a new table that will show each discrete location. To do this, right-click on the Training Requests table and click on Duplicate.
- Rename the new table to Locations
- In the Query Settings pane, click on the Gear for Removed Other Columns step
- Uncheck all columns EXCEPT Id and Locations
- Click on the Locations expand icon
and choose Expand to New Rows. What this does is it creates a new row for each location specified for that item (id).
- Click on Close and Apply
- Next we want to create a relationship between the two tables. Click on the Relationships icon
on the left.
- You should see that Power BI automatically created a relationship for you. Double-click on the link and change Cross filter direction to Both and click on OK
- Go back to the Power BI canvas
- Delete the previous Slicer and add a new Slicer
- In the Fields pane, expand Locations and check Locations
- Now you should see discrete locations in your Slicer giving you the ability to find the Training Requests for each location like below:
- At this point you can add additional visualizations such as bar charts and pie charts and finish building out your Power BI dashboard.