©  Adam Aspin 2018
Adam AspinPro Power BI Desktophttps://doi.org/10.1007/978-1-4842-3210-1_21

21. Using Slicers

Adam Aspin
(1)
Stoke-on-Trent, Staffordshire, UK
 
With your filters in place, you now have some extremely powerful and insightful dashboards ready to be paraded in front of your colleagues, bosses, and clients. Yet static illustrations can only tell a story in a certain way. What you need to clinch the deal or convince an audience is some truly telling interaction with your facts and figures. Once again, Power BI Desktop is the tool of choice, as it highlights the key metrics in your presentation with a single click—and makes your point, simply and elegantly.
Put less breathlessly, you can interact with your filtered data in Power BI Desktop reports to subset or isolate metrics. These elements have the following characteristics:
  • Always visible in the Power BI Desktop report
  • Instantly accessible
  • Interactive
  • Clearly indicate which selections are being applied
So what are the effects that you can add to a Power BI Desktop report to select and project your data? Essentially, they boil down to two main approaches
  • Slicers
  • Highlighting
These interactive elements can be considered to function as a supplementary level of filtering. That is, they take the current filters that are set in the Filters well (at any level) and then provide further fine-grained interactive selection on top of the dataset that has been allowed through the existing filters. Each approach has its advantages and limitations, but used appropriately, each gives you the ability not only to discover the essence of your data, but also to make your point clearly and effectively.
You will use the C:PowerBiDesktopSamplesCH21CarSalesDataForReports.pbix sample file as the basis for all the slicers that you create in this chapter.

Slicers

A key form of interactive filter in Power BI Desktop is the slicer. This is, to all intents and purposes, a standard multiselect filter, where you can choose one or more elements to filter data in a report. The essential difference is that a slicer remains visible on the Power BI Desktop report, whereas a filter is normally hidden. So this is an overt rather than a covert approach to data selection that makes the selection criteria immediately visible. Moreover, you can add multiple different slicers to a Power BI Desktop report and consequently slice and dice the data instantaneously and interactively using multiple, cumulative, criteria. Slicers can be text-based, or indeed, they can be simple charts, as you will soon see.

Adding a Slicer

To appreciate all that slicers can do, we need to see one in action. This means having at least one standard visual in a page so that you can see the result of applying a slicer. To test a slicer
  1. 1.
    Create a table (to show the effect of using a slicer) using the following fields:
    1. a.
      CountryName (from the Countries table)
       
    2. b.
      SalePrice (from the InvoiceLines table)
       
     
  2. 2.
    Resize the table so that it fits the data.
     
  3. 3.
    In the Fields list, expand the Colors table.
     
  4. 4.
    Drag the Color field to an empty part of the dashboard canvas. It will become a single-column table.
     
  5. 5.
    Click the Slicer icon in the Visualizations pane. The table of colors will become a slicer. The Slicer icon is shown in Figure 21-1.
    A370912_2_En_21_Fig1_HTML.jpg
    Figure 21-1.
    The Slicer icon
     
  6. 6.
    Adjust the size of the slicer to suit your requirements using the corner or lateral handles. If the slicer contains many elements, Power BI Desktop will add a vertical scroll bar to indicate that there are further elements available.
     
You can recognize a slicer by the small squares to the left of each element in the list. This way you know that it is not just a single-column table. Figure 21-2 shows a slicer using the Color field.
A370912_2_En_21_Fig2_HTML.jpg
Figure 21-2.
A slicer
Tip
If the Slicer icon is grayed out, then ensure that the table that you are trying to convert to a slicer has only one column (that is, one field in the Values box of the field well for this visual).
You can create multiple slicers for each page. All you have to do is repeat steps 3 through 6 for adding a slicer using a different field as the data for the new slicer.

Applying Slicers

To apply a slicer and use it to filter data on a page, click a single element in the slicer or Ctrl-click multiple elements.
All the objects in a Power BI Desktop page are filtered to reflect the currently selected slicer list. In addition, each element in the slicer list that is active (and consequently used to filter data by that element) now has a small rectangle to its left, indicating that this element is selected.
Figure 21-3 shows what happens when the slicer defined previously is applied to the visualization shown in Figure 21-2.
A370912_2_En_21_Fig3_HTML.jpg
Figure 21-3.
Applying a slicer
When you apply a slicer, think filter. That is, if you select a couple of elements from a slicer based on the CountryName field, as well as three elements in another slicer based on the Color fields, you are forcing the two slicers (filters) to limit all the data displayed in the page to two countries that have any of the three colors that you selected. The core difference between a slicer and a filter is that a slicer is always visible—and that you have to select or unselect elements, not ranges of values.
If you experiment, you will also see that you cannot create a slicer from numeric fields in the source data. A slicer has to be based on a text field. If you need slicers based on ranges of data, then you will need to prepare these ranges in the data model. The CarAgeBucket field is an example of this. Chapters 11 and 12 explain how to add these sorts of fields to a data model.
Tip
If you Ctrl-click all the selected elements in a slicer, you can unselect all the data it represents. This will not clear the Power BI Desktop report, however. Unselecting everything is the same as selecting everything—despite the fact that the selection squares are no longer visible to the left of each element in the slicer. Using Shift-click is no different from clicking a slicer element, however.

Clearing a Slicer

To clear a slicer and stop filtering on the selected data elements in a view, click the Clear Slicer icon at the top right of the slicer. This icon is pointed out in Figure 21-3.
Any filters applied by the slicer to the view are now removed. You will see that each element in the slicer list now has a small empty rectangle to its left, indicating that this element is not selected. No data is now filtered out of the report.
Tip
Another technique used to completely clear a slicer is to click (or Ctrl-click) the last remaining active element in a slicer. This leaves all elements inactive. Additionally, you can Ctrl-click to select every item. So, in effect, removing all slicer elements is the same as activating them all.

Deleting a Slicer

To delete a slicer and remove all filters that it applies for a view, select the slicer and press the Delete key. Alternatively, click the context menu button (the ellipses) that appears at the top right when you hover the mouse pointer over a slicer, and select Remove.
Any filters applied by the slicer to the view, as well as the slicer itself, are now removed.
You can even copy and paste slicers if you wish. This is very useful when you are copying slicers across different Power BI Desktop reports or between report pages.

Converting a Slicer to Another Visual Type

If you intend to use the field that was the basis for a slicer in a table or chart, you do not need to delete the slicer and re-create a table based on the same underlying field. You can merely
  1. 1.
    Select the slicer.
     
  2. 2.
    Click the Table button in the Design ribbon, and select the type of table (table, matrix, or card) to which you want to convert the slicer.
     
The instant that a slicer becomes a table, it ceases to subset the data in the Power BI Desktop report.

Modifying a Slicer

If all you want to do is replace the field that is used in a slicer with another field, then it is probably simplest to do this:
  1. 1.
    Select the slicer that you want to modify.
     
  2. 2.
    Drag the new field over the existing field in the field well.
     
The current slicer field is replaced by the new field and the slicer updates to display the contents of the field that you added. Alternatively, you can delete the slicer and re-create it.
Note
You cannot add more than one data field to a slicer, nor can you drag a new field onto the slicer to replace the existing field.
When you start applying slicers to your Power BI Desktop reports, you rapidly notice one important aspect of the Power BI Desktop filter hierarchy. A slicer can only display data that is not specifically excluded by a report- or page-level filter. For instance, if you add a Color filter at page level and select only certain colors in this filter, you are only able to create a slicer that also displays this subset of colors. The slicer is dynamic and reflects the elements that can be displayed once any report and page filters have been applied—just like any other visual. Consequently, adding or removing elements in a filter causes these elements to appear (or disappear) in a slicer that is based on the filtered field.
If you wish, you can apply a filter specifically to a slicer. This allows you to restrict the elements that appear in a slicer. If you want to do this, then you must apply the filter after step 3 in the previous example and before you convert the table to a slicer. However, be aware that the slicer itself does not give you any indication that it is being filtered; that is, there is no visual-level filter displayed in the Filters well.
Conversely, to remove a filter from a slicer, you need to switch it back to a table and remove the filter, and then switch back to a slicer.
Tip
When you save a Power BI Desktop file containing Power BI Desktop reports with active slicers, the slicer is reopened in the state in which it was saved.

Date Slicers

Selecting ranges of dates can extend the appearance and usefulness of slicers. As this is probably easier to appreciate if you see it in action , I suggest that you try out the following:
  1. 1.
    Open the sample file C:PowerBiDesktopSamplesCH21CarSalesDataForReports.pbix.
     
  2. 2.
    In the Visualizations pane, click the Slicer icon. An empty slicer will be added to the report canvas.
     
  3. 3.
    Expand the DateDimension table and check the FullYear field.
     
  4. 4.
    Drag the left-hand (lower) threshold to the right until the left year field shows 2013.
     
  5. 5.
    Drag the right-hand (upper) threshold to the left until the right year field shows 2015. The slicer will look like the one in Figure 21-4. Any data in the page will be filtered to exclude dates outside this range of years.
    A370912_2_En_21_Fig4_HTML.jpg
    Figure 21-4.
    Slicing on years
     
You can, if you prefer, enter a year directly in one of the year fields in a slicer like this one. However, I feel that the usefulness of a slicer like this is precisely in its ability to alter the threshold values quickly and easily using the slider.
If you use a data field that is set as a date type, then the slicer can help you set dates quickly and easily, but in a slightly different way. Here’s how:
  1. 1.
    In the Visualizations pane, click the Slicer icon. An empty slicer will be added to the report canvas.
     
  2. 2.
    Expand the DateDimension table and check the DateKey field.
     
  3. 3.
    Click inside one of the date fields. The slicer will look like the one in Figure 21-5.
    A370912_2_En_21_Fig5_HTML.jpg
    Figure 21-5.
    A date slicer
     
  4. 4.
    Select the date that you want to set for the date threshold.
     
To make the most of this calendar, you need to know a few tricks:
  • Clicking the up and down chevrons displays the following or preceding month.
  • Clicking the year in the calendar popup displays a list of years. From here you can select the required year.
  • Clicking the month in the calendar popup displays a list of months. From here you can select the required month.
  • You cannot select an upper date that is less than the lower date.
  • The calendar will allow you to select dates that are not included in the underlying table of dates. This, however, can cause some unexpected results to appear in your reports.
Note
Certain fields in a date dimension (sometimes this can mean most of them) are considered as being simple selection elements. So, for instance, using the MonthFull field in a slicer will result in a list of months, without sliders. The best thing to do is to experiment with the various fields that are available in the Date Dimension table and use those that best suit your purposes.

Formatting Slicers

Slicers can be formatted just like any other Power BI Desktop visual. Indeed, many of the techniques that you use to format slicers are identical to those that you have already seen when formatting tables and matrices. Consequently, to avoid pointless repetition, this section concentrates on any formatting attributes that are slicer-specific, and only refers in passing to formatting approaches that you have already covered in previous chapters.

Slicer Orientation

To help you to make the best possible use of report real estate, slicers can be configured to appear vertically (as in Figure 21-2) or horizontally. To switch a slicer’s orientation:
  1. 1.
    Select the slicer that you want to modify. (I selected the colors slicer that you created previously.)
     
  2. 2.
    In the Visualizations pane, click the Format icon.
     
  3. 3.
    Expand the General section.
     
  4. 4.
    In the Orientation popup, select Horizontal.
     
  5. 5.
    Resize the slicer to suit your dashboard. A horizontal slicer will look something like the one in Figure 21-6.
    A370912_2_En_21_Fig6_HTML.jpg
    Figure 21-6.
    A horizontal slicer
     
As you can see in Figure 21-6, a horizontal slicer does not have the small check boxes that a vertical slicer does. Consequently, when a horizontal slicer element is selected, the entire element is in “reverse video.”
You probably also noticed that Power BI Desktop alters the number of rows of text as well as the width of text elements when you resize the slicer. It follows that you are best advised to experiment when altering slicer height and width in order to get the effect that suits you best.

Modifying the Outline

For Power BI Desktop, the outline is the line that separates the title from the items in a slicer. The following discusses how you can format this particular element.
  1. 1.
    Select the slicer that you want to modify. (I used the horizontal colors slicer that you created earlier.)
     
  2. 2.
    In the Visualizations pane, click the Format icon.
     
  3. 3.
    Expand the General section.
     
  4. 4.
    Use the Outline Weight slider to set the weight of the outline to 3 points.
     
  5. 5.
    Click the Outline Color popup and choose a color. The separator line will change to reflect the modifications that you have made.
     

Adjusting Selection Controls

If you are not happy with the way that Power BI Desktop lets you select items in a slicer, then you can adjust the way that you interact with this particular visual. While the Power BI default mode of interaction is probably sufficient in most cases, it certainly does no harm to know that there are other ways of selecting elements in slicers.

Adding or Removing the Select All Box

You can add the Select All box to slicer as follows:
  1. 1.
    Select the slicer that you want to modify. (I used the horizontal colors slicer that you created earlier).
     
  2. 2.
    In the Visualizations pane, click the Format icon.
     
  3. 3.
    Expand the Selection Controls section.
     
  4. 4.
    Slide the Select All switch to the On position. This will add a Select All item to the top (or left) of the slicer.
     
Should you not want a Select All item in a slicer, all you have to do is ensure that the Select All switch is set to Off in step 4.

Enabling Single Select

A slicer’s default mode is to select only a single item, unless the user Ctrl-clicks several items. If you prefer to add items one at a time—and deactivate them individually too—you can enable Single Select to do just this. Simply follow these steps:
  1. 1.
    Select the slicer that you want to modify. (I used the horizontal colors slicer that you created earlier).
     
  2. 2.
    In the Visualizations pane, click the Format icon.
     
  3. 3.
    Expand the Selection Controls section.
     
  4. 4.
    Slide the Single Select all switch to the Off position. This will set the slicer interaction to single select. You can see the result of this operation—and what happens when you add a Select All element—in Figure 21-7.
    A370912_2_En_21_Fig7_HTML.jpg
    Figure 21-7.
    Altering a slicer’s selection controls
     

Setting the Exact Size and X and Y coordinates of a Slicer

If you want to place a slicer with total accuracy on a dashboard canvas, then you can set the X and Y (horizontal and vertical) coordinates for the slicer. You can also specify its exact height and width. The following explains how:
  1. 1.
    Select the slicer that you want to modify.
     
  2. 2.
    In the Visualizations pane, click the Format icon.
     
  3. 3.
    Expand the General section.
     
  4. 4.
    Replace the X Position, Y Position, Width, and Height values with the pixel values that define the size and position of the slicer that you wish to apply.
     

Formatting the Slicer Header

Should you want to add some visual pizzazz to a slicer, you can tweak the display of the slicer header. Here is an example of how to do this:
  1. 1.
    Select the slicer that you want to modify. (I used the horizontal colors slicer that you created earlier).
     
  2. 2.
    In the Visualizations pane, click the Format icon.
     
  3. 3.
    Expand the Header Controls section.
     
  4. 4.
    Ensure that the Header switch is in the On position.
     
  5. 5.
    Click the Font Color popup and choose a color for the header text.
     
  6. 6.
    Click the Background Color popup and choose a color for the header background.
     
  7. 7.
    Adjust the Text Size slider to tweak the size of the header text.
     

Formatting Slicer Items

Slicer items are the individual elements that make up the list of data that appear in a slicer, based on the underlying field. These, too, can be formatted to focus the attention of the reader . Here’s an example:
  1. 1.
    Select the slicer that you want to modify. (I used the horizontal colors slicer that you created earlier.)
     
  2. 2.
    In the Visualizations pane, click the Format icon.
     
  3. 3.
    Expand the Items section.
     
  4. 4.
    Click the Font Color popup and choose a color for the item text.
     
  5. 5.
    Click the Background Color popup and choose a color for the background of each item.
     
  6. 6.
    Adjust the Text Size slider to tweak the size of the text of each item.
     
  7. 7.
    Click the Outline popup and select Frame.
     
You can also format the following aspects of a slicer:
  • Background
  • Title
  • Lock aspect ratio
However, since all of these are identical to formatting attributes that apply to tables and charts (and that you have seen in previous chapters), I will not repeat the description of them.
Finally, Figure 21-8 shows you a slicer with many of the formatting options that you just saw.
A370912_2_En_21_Fig8_HTML.jpg
Figure 21-8.
A formatted slicer

Sorting Slicer Elements

The elements in a slicer will be displayed in alphabetical order. If you wish, you can reverse this sort order, as follows:
  1. 1.
    Click the ellipses at the top right of the slicer.
     
  2. 2.
    Select Sort By Color (or whatever the field name is).
     
The slicer elements will now be displayed in reverse alphabetical order.
Tip
You can add a Sort By column to any data field that you wish to display in another sort order.

Switching to Dropdown Slicers

Slicers are amazingly useful, but they do have one drawback: they can take up a lot of valuable screen space. So the development team at Microsoft has come up with an elegant solution. This is to use dropdown slicers, where the slicer elements only appear when you click a popup menu.
To convert an existing slicer to a dropdown slicer:
  1. 1.
    Select an existing slicer (or hover the mouse pointer over it). I will use the colors slicer that you have used so far in this chapter.
     
  2. 2.
    Click the chevron on the top right next to the Clear Selections icon. A popup menu will appear, as you can see in Figure 21-9.
    A370912_2_En_21_Fig9_HTML.jpg
    Figure 21-9.
    Switching to dropdown slicer
     
  3. 3.
    Select Dropdown. The slicer will convert to a dropdown slicer. You can see what this now looks like in Figure 21-10.
    A370912_2_En_21_Fig10_HTML.jpg
    Figure 21-10.
    A dropdown slicer
     
  4. 4.
    Click the chevron for the slicer popup list and select the element that you want to slice the data on.
     
Tip
Dropdown slicers can be particularly useful when designing Power BI reports for mobile phones.

Exporting Slicer Data

Slicer data can be exported just like the data in any other visual:
  1. 1.
    Click the ellipses at the top right of the slicer.
     
  2. 2.
    Select Export Data.
     
  3. 3.
    Browse to the desired directory and enter a file name.
     
  4. 4.
    Click Save.
     

Using Charts As Slicers

You have seen how a table can become a slicer, which is a kind of filter. Well, charts can also be used as slicers. Knowing how charts can affect the data in a Power BI Desktop report can even influence the type of chart that you create, or your decision to use a chart to filter data rather than a standard slicer. Charts can be wonderful tools to grab and hold your audience’s attention—as I am sure you will agree once you have seen the effects that they can produce.

Charts As Slicers

To begin with, let’s see how a chart can be used to act as a slicer to filter data interactively for any or all of the visualizations in a Power BI Desktop report. Initially, let’s assume that we are aiming to produce a report using two objects:
  • A Cost Plus Spares by Color table
  • A Spare Parts by Make column chart
Let’s create a Net Margin by Color table. It is principally used to show the effect that using a chart as a slicer in a Power BI Desktop report has on other objects. As an added extra, you will apply a filter to the page to demonstrate that filters and slicers work together, as described.
  1. 1.
    Open the C:PowerBiDesktopSamplesCH21CH21CarSalesDataForReports.pbix file and delete any existing visuals. You will need an entire uncluttered report for this example.
     
  2. 2.
    Expand the DateDimension table and drag the FullYear field into the Page Level Filters box in the Filters well.
     
  3. 3.
    Set the Filter Type popup to Basic Filtering.
     
  4. 4.
    Check the box for the year 2014. This way, you have filtered the page to display only data for 2014.
     
  5. 5.
    Add a table based on the following fields:
    1. a.
      Color (from the Colors table)
       
    2. b.
      CostPlusSpares (from the InvoiceLines table)
       
     
  6. 6.
    Add a bar chart based on the following fields:
    1. a.
      Make (from the Stock table)
       
    2. b.
      SpareParts (also from the Stock table)
       
     
  7. 7.
    Click the popup menu for the bar chart (the ellipses that appear at the top right of the visual when you place the mouse pointer over the chart).
     
  8. 8.
    Click the ellipses at the top right of the chart and then select Sort By SpareParts. This will sort the bar chart in descending order.
     
  9. 9.
    Adjust the layout of the two visualizations so that it looks something like Figure 21-11.
    A370912_2_En_21_Fig11_HTML.jpg
    Figure 21-11.
    Preparing a chart for use as a slicer
     
To see how to use a chart as a slicer, click any column in the chart of parts costs by make. I will choose Jaguar in this example.
The Power BI Desktop report will look something like Figure 21-12.
A370912_2_En_21_Fig12_HTML.jpg
Figure 21-12.
Slicing data using a chart
You will see that not only is the make that you selected highlighted in the chart (the bars for other makes are dimmed), but that the figures in the table also change. They, too, only display the cost plus spares (for each color) for the selected make.
To slice on another make, merely click the corresponding column in the column chart. To cancel the effect of the chart acting as a slicer, all you have to do is click for a second time on the highlighted column.
Any bar chart, pie chart, or column chart can act like a slicer in this way, as can funnel charts, treemaps, scatter charts, bubble charts, and maps. The core factor is that for a simple slice effect, you need to use a chart that contains only one axis; that is, there will only be a single axis in the source data and no color or legend. What happens when you use more evolved charts to slice, filter, and highlight data is explained next.
Tip
It is perfectly possible to select multiple bars in a chart to highlight data in the same way that you can select multiple elements in a slicer. Simply Ctrl-click to select multiple items.

Highlighting Chart Data

So far, we have seen how a chart can become a slicer for all the visualizations in a dashboard page. However, you can also use another aspect of Power BI Desktop interactivity to make data series in charts stand out from the crowd when you are presenting your findings. This particular aspect of data presentation is called highlighting .
Once again, highlighting is probably best appreciated with a practical example. First, we will create a stacked bar chart of parts and labor costs by CountryName; and then we will use it to highlight the various costs inside the chart.
  1. 1.
    In a blank Power BI Desktop report (so you do not get distracted), create a clustered column chart based on the following fields:
    1. a.
      CountryName (from the Countries table)
       
    2. b.
      SpareParts (from the Stock table)
       
    3. c.
      LaborCost (from the Stock table)
       
     
  2. 2.
    Click SpareParts in the legend. All the sales costs will be highlighted (that is, remain the original color) in the column for each country, whereas the other cost will be grayed out.
     
After highlighting has been applied, the chart will look like Figure 21-13.
A370912_2_En_21_Fig13_HTML.jpg
Figure 21-13.
Highlighting data inside a chart
To remove the highlighting, all you have to do is click a second time on the same element in the legend. Or, if you prefer, you can click another legend element to highlight this aspect of the visualization instead. Yet another way to remove highlighting is to click inside the chart, but not on any data element.
Highlighting data in this way should suit any type of bar or column chart as well as line charts. It can also be useful in pie charts where you have added data to both the Axis and Legend boxes, which, after all, means you have multiple elements in the chart just as you can have with bar, column, and line charts. You might find it less useful with scatter charts.

Cross-Chart Highlighting

Cross-chart highlighting adds an interesting extra aspect to chart highlighting and filtering. If you use one chart as a filter, the other chart is updated to reflect the effect of selecting this new filter not only by excluding any elements (slices, bars, or columns) that are filtered out, but also by showing the proportion of data excluded by the filter.
As an example of this, create a pie chart of cost price by color and a column chart of direct costs by vehicle type. We will then cross-filter the two charts and see the results. The steps to follow are
  1. 1.
    Create a pie chart using the following fields:
    1. a.
      Color (from the Colors table)
       
    2. b.
      CostPrice (from the Stock table)
       
     
  2. 2.
    Create a (clustered) column chart using the following fields:
    1. a.
      Vehicle (from the Stock table)
       
    2. b.
      CostPrice (from the Stock table)
       
    For charts that are this simple, Power BI Desktop automatically attributes the fields to the correct boxes in the Fields list once the source tables are converted into charts. The result is shown in Figure 21-14.
    A370912_2_En_21_Fig14_HTML.jpg
    Figure 21-14.
    Preparing charts for cross-chart highlighting
     
  3. 3.
    Now click the largest slice in the pie chart (Canary Yellow). You should see the result given in Figure 21-15. Not only have all the other segments of the pie chart been dimmed, but the bars in the bar chart have been highlighted to show the proportion of the selected color of the total sales cost per vehicle cost.
    A370912_2_En_21_Fig15_HTML.jpg
    Figure 21-15.
    Cross-chart highlighting
     
  4. 4.
    Now click the bar in the bar chart representing Aston Martin DB9. You are now using the bar chart as a slicer. As you can see in Figure 21-16, the pie chart displays the proportion of Aston Martin DB9 sales for each color.
    A370912_2_En_21_Fig16_HTML.jpg
    Figure 21-16.
    Cross-chart highlighting applied to a pie chart
     
Note
When you use a filter, you do not highlight a chart but actually filter the data that feeds into it; consequently, you remove elements from the chart. Highlighting leaves elements in a chart but accentuates certain aspects of the data relative to others.

Highlighting Data in Bubble Charts

Often when developing a visualization whose main objective, after all, is to help you to see through the fog of data into the sunlit highlands of comprehension, profit, or indeed, whatever is the focus of your analysis, you may feel that you cannot see the forest for the trees. This is where Power BI Desktop’s ability to highlight data in a chart visualization can be so effective.
Let’s take a visualization that contains a lot of information; in this example, it is a bubble chart of vehicle types. Indeed, in this example, an audience might think that there is so much data that it is difficult to see the bubbles for specific makes of car, and so analyze the uniqueness for sales data by make. Power BI Desktop has a solution to isolate a data series in such a chart. To see this in action and to make the details clearer, you need to do as follows:
  1. 1.
    Create a bubble chart (remember that this is a scatter chart, really) using the following elements:
    1. a.
      X Axis: Average Parts Cost Ratio (from the Stock table)
       
    2. b.
      Y Axis: SalePrice (from the InvoiceLines table)
       
    3. c.
      Size: GrossMargin (from the InvoiceLines table)
       
    4. d.
      Details: Color (from the Colors table)
       
    5. e.
      Legend: VehicleType (from the Stock table)
       
     
  2. 2.
    In the legend for the chart, click a vehicle type. I used saloon (the British word for sedan in the US) in this example. The data for this vehicle type is highlighted in the chart, and the data for all the other vehicle types are dimmed, making one set of information stand out. This is shown in Figure 21-17.
    A370912_2_En_21_Fig17_HTML.jpg
    Figure 21-17.
    Highlighting data in bubble charts
     
This technique needs a few comments:
  • To highlight another dataset, merely click another element in the legend.
  • To revert to displaying all the data, click the selected element in the legend again.
  • Highlighting data in this way also filters data in the entire page, as described previously.
Tip
You can add drill down to charts and still use chart highlighting in exactly the same way as you would use it normally, provided that you have disabled drill down using a chart element, as described in Chapter 16. In this case, you have to drill down (as well as up) using the Drill icons. The chart highlights an element at a drill-down level or sublevel, as well as applying filtering to the Power BI Desktop report.

Charts As Complex Slicers

Now that you have seen how charts can be used as slicers, let’s take things one step further and see them used as more complex slicer elements . To show this, I build on the principles shown in the previous example, but add a bubble chart that will slice data on two elements at once.
Follow these steps for the purposes of this example:
  1. 1.
    Build a Power BI Desktop report with the following:
    1. a.
      A SalePrice by CountryName and Color matrix
       
    2. b.
      A net sales by Make clustered column chart
       
     
  2. 2.
    Create a bubble chart using the following data:
    1. a.
      X Axis: SalePrice (from the InvoiceLines table)
       
    2. b.
      Y Axis: SpareParts (from the Stock table)
       
    3. c.
      Size: Weeks In Stock (from the Stock table)
       
    4. d.
      Details: CountryName (from the Countries table)
       
    5. e.
      Legend: Color (from the Colors table)
       
     
  3. 3.
    Resize and tweak the bubble chart so that it is displayed under the existing column chart and table.
     
  4. 4.
    Click the bubble next to the top-right bubble in the bubble chart. The Power BI Desktop report should look like Figure 21-18. The tooltip indicates which bubble has been used to filter the other visuals.
    A370912_2_En_21_Fig18_HTML.jpg
    Figure 21-18.
    Highlighting and filtering using a chart
     
You can see that the other visualizations are filtered so that both the elements that make up the individual bubble (CountryName and Color) are used as filters (or double-slicers if you prefer to think of them like that). This means that
  • The table only shows colors where there are sales for this country and this color.
  • The chart highlights data for this country and color only.
As was the case with simple chart slicers, you can cancel the filter effect merely by clicking for a second time on the selected bubble. Or you can switch filters by clicking another bubble in the bubble chart. You will also see the chart itself has data highlighted, but this is explained a little further on.
Clearly, you do not have to display the fields on which you are filtering and highlighting in all the visualizations in a report. I chose to do it in this example to make the outcome clearer. In the real world, all other visualizations in a report are filtered on the elements in the Details and Legend boxes of the bubble chart.
Bubble charts are not the only chart type that lets you apply two simultaneous filters , however. All chart types that display multiple fields allow this. However, I am of the opinion that some charts are better suited than others to this particular technique. Specifically, I am not convinced that line charts are always suited to being used as filters for a Power BI Desktop report. Scatter charts may work—visually, that is—if you use cross-filtering, but it is just as likely that they will not. Stacked bar and stacked column charts can be ideal for cross-filtering, as you will see in the following sections.

Column and Bar Charts As Filters

Column charts and bar charts can also be used to filter a Power BI Desktop report on two elements simultaneously. The only limitation is that you can only have one set of numeric data as the values for the chart. If the bar or column chart is a stacked bar, then you can click any of the sections in the stacked bar. In addition, if the chart is a clustered bar or column, you can click any of the columns in a group to slice by the elements represented in that section.
If this limitation is not a problem, then this is how you can use bar or column charts (whether they are clustered, stacked, or 100% stacked) to apply double filters to a report:
  1. 1.
    Create a Power BI Desktop dashboard using the C:PowerBiDesktopSamplesCH21CarSalesDataForReports.pbix file with the following two elements:
    1. a.
      A matrix based on color, country name, sales price, gross margin, and cost price. Once the matrix is created, click the Expand all down one level icon in the hierarchy to see all the levels of data.
       
    2. b.
      A clustered bar chart of sales price by country name.
       
     
  2. 2.
    Then create a stacked column chart using the following data:
    1. a.
      Values: GrossMargin (from the InvoiceLines table)
       
    2. b.
      Axis: CountryName (from the Countries table)
       
    3. c.
      Legend: VehicleAgeCategory (from the Stock table)
       
     
Once tweaked to clarify the appearance of the chart, the net result should look like Figure 21-19.
A370912_2_En_21_Fig19_HTML.jpg
Figure 21-19.
A report ready for chart-based filtering and highlighting
Clicking any segment of a bar filters and highlights other visualizations on the same report for that country and car age range. An example of this is given in Figure 21-20, where the car age range of 21–25 has been selected for the USA bar.
A370912_2_En_21_Fig20_HTML.jpg
Figure 21-20.
Applying filters and highlights
Clicking any car age range in the legend will filter by car age range only. You see this in Figure 21-21, where the legend item for 16-20 has been selected.
A370912_2_En_21_Fig21_HTML.jpg
Figure 21-21.
Filtering using a legend element
So in fact, you can choose to filter on a single element or multiple elements, depending on whether you use the chart or the legend as the filter source.
Note
A line chart will not produce the same effect when you click only a data point. If you click a series in a line chart, you are highlighting that series, which is numeric data, and so it cannot be used as a slicer. Similarly, if you click an element in the legend of a column or bar chart, you are selecting a data series, and this, too, cannot serve as a slicer (even though it highlights the series in the chart).

Specifying Visual Interactions

In the previous few sections, you saw that the effects of selecting one or more items in a slicer are applied automatically to every visual on a page, as will the effects of using a chart as a slicer. This is indeed true, and is the default behavior of Power BI Desktop unless you specifically configure a visual not to react when a chart or slicer on the page has items selected.
In effect, this means that you can attain a tremendous degree of subtlety in your dashboards, because you can define which visuals are to remain interactive—and which must not change when a slicer, chart, or multiple slicers and charts are used.
The following explains how to alter the default setting, and remove interactivity from a visual. You need to be aware that you need at least two visuals in a report to carry out this modification.
  1. 1.
    Select the visual that you want to prevent having a highlighting effect on other visuals.
     
  2. 2.
    In the Home ribbon, click the Edit Interactions button. All the other visuals on the page will display the interaction icons that you can see in Figure 21-22 (a funnel and a “no entry” sign).
    A370912_2_En_21_Fig22_HTML.jpg
    Figure 21-22.
    The visual interaction icons for visuals
     
  3. 3.
    Click the Stop Interaction icon (the “no entry” sign) in another visualization. I used the table of sales by country that you created previously. This icon will appear filled in, as shown in Figure 21-23.
    A370912_2_En_21_Fig23_HTML.jpg
    Figure 21-23.
    The visual interaction icons set to prevent interaction
     
  4. 4.
    Repeat steps 2 through 5 for all visuals that you want to “disconnect” from the selected visual.
     
  5. 5.
    In the Home ribbon, click the Edit Interactions button to stop configuration of visual interaction.
     
You can then iterate through all the charts and slicers on a page to set their dependency on another element.
Note
A slicer can also be linked to or dependent on another slicer on the page. Consequently, you can set the interaction for a slicer just as you can for any other visual.

What-If Slicers

A really interesting (and fairly new) feature in Power BI Desktop is the ability to interact with data using what-if slicers . These allow you to define variable values that are then applied to the data in the data model for any fields that you choose. You can then adjust the what-if value in a slider on screen and watch the calculated values change in real time.
This feature is best appreciated if you experiment with it. So here is one example of a what-if slicer. Let’s suppose that you want to see what happens to gross margin if suppliers increase the cost of spare parts.
  1. 1.
    In the Modeling ribbon, click the New Parameter button.
     
  2. 2.
    Enter SparePartsVariation in the Name box.
     
  3. 3.
    Select Decimal Number as the data type from the Data Type popup list.
     
  4. 4.
    Leave the Minimum value as 0, and enter 0.5 (50 percent) as the Maximum value.
     
  5. 5.
    Set the increment to 0.02 (two percent). The dialog will look like the one in Figure 21-24.
    A370912_2_En_21_Fig24_HTML.jpg
    Figure 21-24.
    The What-If Parameter dialog
     
  6. 6.
    Click OK. Power BI Desktop will add a new table to the data model named SparePartsVariation as well as a slicer to the desktop canvas. After resizing the slicer, you can see these, as well as the data in the new table, in Figure 21-25.
    A370912_2_En_21_Fig25_HTML.jpg
    Figure 21-25.
    A what-if slicer
     
  7. 7.
    Click the SparePartsVariation table in the Fields list and then click New Column in the Modeling ribbon.
     
  8. 8.
    Enter the following formula in the Formula bar (this will calculate a new spare parts cost using the multiplier from the what-if slicer):
    SparePartsNew = SUM(Stock[SpareParts]) + (SUM(Stock[SpareParts]) * 'SparePartsVariation'[SparePartsVariation Value])
     
  9. 9.
    Create a clustered column chart using the following fields:
    1. a.
      Make (from the Stock table)
       
    2. b.
      SpareParts (from the Stock table)
       
    3. c.
      SparePartsNew (from the SparePartsVariation table)
       
     
  10. 10.
    Adjust the slider to apply a new percentage increase in the cost of spare parts. The resulting chart and slicer will look like those in Figure 21-26.
    A370912_2_En_21_Fig26_HTML.jpg
    Figure 21-26.
    A what-if slicer applied to a chart
     
The values that you add in the table that underlies the what-if slicer can be fixed values, percentages—anything you like. Moreover, you can create as many new measures based on the what-if value as you want to.

Custom Visuals As Slicers

There are many excellent third-party visuals available that are designed to be slicers. This section provides a few pointers to some of the currently available third-party slicers. These are only a few of the slicers that you can find. Once again I have limited the selection to third-party visuals developed by Microsoft.

Timeline Slicer

The timeline slicer lets you drag the upper and lower limits of a date range. You can also define the date element (year, quarter, month, week, or day) to use interactively. You can see this in Figure 21-27.
A370912_2_En_21_Fig27_HTML.jpg
Figure 21-27.
The timeline slicer

Timebrush Slicer

A timebrush slicer allows you to highlight a section of a time-ordered dataset. You can see this in Figure 21-28.
A370912_2_En_21_Fig28_HTML.jpg
Figure 21-28.
The timebrush slicer

Chicklet Slicer

A chicklet slicer is a slicer that you can arrange and format in a multitude of ways. You can see a simple example in Figure 21-29.
A370912_2_En_21_Fig29_HTML.jpg
Figure 21-29.
The chicklet slicer
This particular slicer really does add a multitude of options. I strongly recommend that you take a look at all that it can do.

Choosing the Correct Approach to Interactive Data Selection

Now that you have taken a tour of the interactive options that Power BI Desktop offers, it is worth remembering that there is a fundamental difference between slicers and chart filters:
  • Slicers and chart filters apply to all visuals on the Power BI Desktop page. Unless you have tweaked the visual interactions
  • Highlighting only applies to the selected chart, although it filters data in other tables and highlights the percentage of this element in other charts.

Conclusion

In this chapter, you have seen how to use the interactive potential of Power BI Desktop to enhance the delivery of information to your audience. You saw how to add slicers to a report, and then how to use them to filter out data from the visualizations it contains. Then, you learned how to highlight data in charts. Next, you saw how to use charts as interactive slicers to isolate specific elements in a presentation.
Finally, you saw how to apply what-if slicers and took a peek at some of the third-party slicers that are available.
These techniques are powerful tools that can dramatically enhance the way that you present data to an audience. Used carefully, they will help your dashboards become more powerful and even more memorable. So all that remains is for you to start applying these techniques using your own data. Then you can see how you can impress your audiences using all the interactive possibilities of Power BI Desktop.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.228.19