Measure Selection using Slicers in PowerPivot

As a Business Intelligence professional, I find it really fascin(/frustr)ating working with Excel users. You get exposed to a completely different way of thinking when you work with them, not to say that they are extremely smart and demanding. From the moment I started working with PowerPivot and interacting with Excel users, I knew it was not going to be easy tackling their questions and requirements. You simply cant escape by saying that the required feature is not available because they will push you till you find a workaround. This was the case when one of my users came back to me asking for a slicer which will dynamically help them to select the measures. I replied saying that the slicers are not intended for that purpose and should be used for filtering the data (and not for just selecting or deselecting values like Measures, which can be easily done from the Field List pane). However, the user pushed back saying that he would like to create a dashboard for the top management and didn’t want them to be using the Field List pane. That is when I had to put on my thinking cap. For the purpose of this post, I am going to use some simple mocked up data which involves three measures (Sales, Quantity and Profit) for country and year. Follow the steps below to recreate a slicer which can be used to select or deselect the measures in a pivot table:- 1) Create a table which will have the list of measure names needed in the slicer in the MeasureName column and their representative integer ids in the MsrId column. Import this table into PowerPivot using Linked Tables and name it as Msr. There is no need to make any relations with the existing tables, and Msr table should be a standalone table. 2) Now make a new measure called MsrValue with the formula given below MsrValue:=switch (TRUE,Min ( Msr[MsrId] ) = 1,Sum ( Fct[Sales] ),Min ( Msr[MsrId] ) = 2,Sum ( Fct[Quantity] ),Min ( Msr[MsrId] ) = 3,Sum ( Fct[Profit] )) This measure will check the value of the MsrId column, and then use the appropriate measure. However, it should be noted that when there are more than one value of MsrId (or if more than one measures are selected), only the measure having minimum value of MsrId would be displayed. So how will we display more than one measures on the pivot table? Read on. 3) With this very simple setup, we are ready to view the results in the Pivot table. Drag and drop MeasureName column into the Slicer, Year into the Column Labels and Country in the Row Labels. Then drag and drop MsrValue in the Values and we should have something similar to the image below. I have also included the fact rows above the pivot so that we can compare. Now there are a couple of problems with this pivot table. You would have noticed that the pivot table works correctly if only one measure is selected, but if there are more than one selections for the measure name, it will only show the measure with the minimum of the MsrId (eg, Sales in the image above). Also, we would like to see the name of the measure in the column above for clarity. To solve both of these problems, follow the next step. 4) Just drag and drop the MeasureName column in the Column Labels above the Year. Now you can see that multiple measures are displayed and also that the measure names are displayed in the column above. You can also change the formatting of the measures if needed MsrValue:=switch (TRUE,Min ( Msr[MsrId] ) = 1,FORMAT ( Sum ( Fct[Sales] ), “$#,#0” ),Min ( Msr[MsrId] ) = 2,format ( Sum ( Fct[Quantity] ), “#,#0” ),Min ( Msr[MsrId] ) = 3,format ( Sum ( Fct[Profit] ), “$#,#0” )) Luckily, that wasn’t as hard as I thought (which means that I could still use my evening free time to focus on more important problems like whether the chicken or egg came first into the world!). If you don’t have such important problems to focus on like me, you can download the completed file from this link and test it out on your own!

Used this technique on a PowerPivot table with < 200 rows (but a lot of columns). Included 17 measures in the SWITCH function. When added to a slicer, one selection worked fine but with a multiple selection, it choked on my 32-bit system. Apparently, the memory requirements for this are very high.

Does anyone know if there is an alternative if using PowerPivot 2008R2? The switch command does not seem to be available. We are currently stuck on PowerPivot 2008R2 until we can get SharePoint updated. I would appreciate thoughts- If I get an answer I'll loop everyone in!

I am extremely interested in using this technique to help make dashboards able to display a number of different measures in Fixed amount of space. I have done my best to use your code to create a "slicer driven" measure selection in a model that contains a number of measures all displaying different calculations of web site "hits" (I use the term Impressions.

My issue is that the actual numbers displayed by the measures shown using the "selected formula" noted above, is different from what those same measures display when they are used independently. Worse, the independently placed measures show considerably more data. For example, I have values of the "independent measures for each month of the year. But, the measure values displayed through the selector process only shows 4 or 5 months.

The "measure driven" values are always higher than the independent measures by themselves, but I can't see any other pattern. I have tried two different version of the formula above — one used the calculated measure names themselves. The other used the formulas themselves.

Also, none of the calculations are complex. THey are all simply sums or averages.

One small question is when I use this it doesnt filter other criteria down to those that have values. For example I am showing Gr Hrs by plant, filtered by year from another slicer. When I use the regular measure, it will only show plants that have hours for the given year, but when i use the switch formula, it shows all plants that have ever had hours, with the value being blank.

Aware this post is very old but really like this idea. When I implemented it (in Excel 2010) I got everything to work as I wanted, EXCEPT that the FORMAT command you used meant my table returned text values, rather than useable currency/percentage values. As I wanted to chart the outcomes this was no good to me. IS there anything I can tweak to return useable currency/percentage values?

Absolutely could, but wanted to offer user chance to select measure (varying between currency and %) and have the graph scale automatically adjust to either $ or %. Thanks anyway for your response though.

Really appreciate this solution. Like I believe has already been mentioned, I seem to have a issue that when the FORMAT() function is applied, i get BLANK rows that don't show up otherwise. Is there a work around for this?

[…] of this demo, let us use the PowerPivot file that I created in Excel 2010 for my last post – Measure Selection using Slicers in PowerPivot. You can download it from this link. If you open it in Excel 2010, you can see the original table […]

Forgot to mention a fantastic thing about it. I have loads of measures in Power Pivot. This solution allowed me to “hide from client” my entire sales data including calculated measures, with the only thing elegantly showing in the pivots field list being “Measures” ! 🙂 Thanks again!

I realize this is an old post, but this approach worked great for me. One additional question… Is there a way to calculate a variance in your example above. For example, the variance between 2011 and 2012 for both Quantity and Profit in your example above?

I tried that, but it results in multiple columns of same data.
My table has a version (act, plan, ly) in a single column going down the rows, and my accounts (Sales Qty, Dollars, Margin) in each column.
So, when I try to calculate a difference for Sales Qty for act vs. plan, I get three columns showing the same data in the Act, Plan, LY columns. I would like this to look a bit cleaner for the users. (I apologize, but I am a beginner at this.)

send me an email to jason143@gmail.com, with some sample data and your measure expression. Also, put a picture on how you want the end result to look. The better the detail, the easier it makes my life and the faster you get a response 🙂