Data Ambiguity…The Silent Report Killer

Hello P3 Nation, I’m excited to be back and writing a technical post again…it’s been too LONG! Today I want to talk to you about a real-world business problem and solution I encountered last year. I think it’s a scenario at least a few of you will relate to. I was working on a project for a client, and needed to create a Power BI report for them.

However, the client didn’t think the active filters in the report were easy to identify. Now this is a scenario I’ve encountered a few times over the years, whether it’s been in Power BI, Excel, or other reporting tools. Overall it comes down to this, data ambiguity can render a report A) Untrustworthy, B) Dangerous, or C) Useless. Personally, I think a well-designed Power BI report has clear “enough” call-outs on the filters. Truth be told though, it only partially matters what we think. At the end of the day, we need to cater the report to the client’s needs.

Please click here to download the workbook to follow along.

Typical report layout I create. Primary sections for – Headers, Slicers, Visuals/Tables:

Power_BI_Report_Before_Filter_Cards

“I Can See (Filters) Clearly Now”

The client and I brainstormed, and we decided to create card visuals to identify filter selections. The beautiful thing about DAX, as mentioned in many articles on our site, is that it can easily return text values. I actually did something similar to this with Dynamic Titles when I posted about Power BI’s new Drill Through feature last year, that article can be found here. So, I essentially wanted to do something similar here, but to call out the filter selection for each slicer. The end result looked something like this

Same report with additional section for slicer filter selection:

Power_BI_Report_After_Filter_Cards

The end result was a new section of the report, dedicated to calling out slicer selections. The BIGGEST reason the client wanted this, was for screenshots. They often took screenshots of this report, and pasted it into emails or slides to use in presentations. The result works well, and uses a bit of clever DAX to always return the right selections, no matter the combination of selections among the slicers.

DAX (SELECTEDVALUES) To The Rescue!

To get the right output with DAX I utilized one of the newer functions, Selected Values. Selected Values is used whenever you use the What If feature in Power BI Desktop. In fact…if you look at my screenshots above, the Rolling Avg Months & Expense Ratio What Ifs are attached to Selected Values measures. Selected Values works like this, you give it a column reference, let’s say [Column A]. If there’s a selected value (E.g. single selection) on that column, it returns that value. Otherwise there’s an alternative result returned. Here’s what the DAX Measure looks like for the Expense Ratio Value.

     Expense Ratio Value = SELECTEDVALUE(‘Expense Ratio'[Expense Ratio], 0.50)

Selected Values is a fairly simple, and straight forward function. For a thorough and in-depth article on it’s uses and abilities, I’ll refer you to a post Marco Russo wrote over at SQLBI. I figured I could use this function to point to my slicer columns, and return a “No Selection” alternative result if there wasn’t. I thought that’s all I’d need, just rinse and repeat a bunch of Selected Values measures, and I’d be done! Not quite…I noticed a few issues after I did this.

Filter Issue Number One

I quickly realized that I was getting false positive filter selections when using certain slicers. As an example, whenever I made a specific selection on Employee Sales Region, sometimes the filter selection for Employee Team Name would change too! What was happening is there was a Sales Region with only a SINGLE Team name. It was triggering the Selected Value logic, because only a SINGLE VALUE was being given to it.

False positive filter selection, despite no selection on the slicer:

Power_BI_ISFILTERED_Problem

I needed my DAX measure to run ONLY when there’s an ACTIVE filter on the column. Selected Values doesn’t check to see if the column has an active filter on it, instead it’s only checking to see if there’s a single value from that column. Some additional business logic would need to be applied to it, to FIRST check for active filtering BEFORE running the Selected Values logic. I worked through a few variations, and eventually ended up using the DAX Function ISFILTERED.

     Employee Sales Region Selection = IF( ISFILTERED(‘Employee Details'[Employee Team Name]), SELECTEDVALUE(‘Employee Details'[Employee Team Name], “No Selection”), “No Selection”)

Filter Issue Number Two

ISFILTERED worked, and I no longer got a false positive filter selection! However, further testing unveiled a second problem. The other issue aired its ugly head whenever a slicer had multiple selections on it. Now my DAX is returning a false negative! I want it to return “Multiple Selections” if I have TWO or more slicer selections. This will be an easy enough fix actually.

The Employee Sales Region Selection DAX (above) has two conditions it’s checking. Condition one (ISFILTERED) is checking if there’s an ACTIVE filter on the column. If that condition is met, then it checks condition two (SELECTEDVALUES), which checks to see if there’s only ONE value coming from that column. If that second condition isn’t met, it returns “No Selection” at the inner most part of the query. All we have to do is update the alternative result in condition two, and change it to “Multiple Selections“.

     Employee Sales Region Selection = IF( ISFILTERED(‘Employee Details'[Sales Region]), SELECTEDVALUE(‘Employee Details'[Sales Region], “Multiple Selections”), “No Selection”)

BEFORE – Multiple selections on the slicer, but no indication of filters on the card:

Power_BI_Multiple_Selection_Problem

AFTER – Multiple selections on the slicer, Multiple Selections indicator on card:

Power_BI_Multiple_Selection_Solution

It’s also possible to return the entire list of selected values, instead of “Multiple Selections”. In fact, Rob has a great post on how to do JUST THAT. It utilizes a DAX Function called CONCATENATEX, and I’d recommend giving it a read. I didn’t go that route, as the client was happy just having multiple selections as the output for this scenario. There you have it folks, a great way to add a bit of clarity to your report. In case youever need a really obvious call-out for your slicer selections. I’m glad to be back in the technical saddle a bit on post writing, look forward to some more posts from me this spring!

  Subscribe to PowerPivotPro!
X

Subscribe

Reid Havens

Reid Havens is the Founder & CEO of Havens Consulting Inc. He has a formal background in technology and organizational management, having obtained separate degrees in Organizational Development & Business Analytics. Reid has experience working with Fortune 500 companies such as Microsoft as well as with Non-Profit Organizations. He is also the Executive Editor, contributing author, and Principal Consultant at PowerPivotPro. Additionally he's an instructor at the University of Washington and other universities, teaching Business Intelligence, Reporting, & Data Visualization. 

This Post Has 27 Comments

  1. Excellent article – I use the ‘Selected Value to provide dynamic titles for reports. Is it possible to configure the Filter Selection Cards so that the ‘Filter Title’ precedes the ‘filtered value’ – believe that this is more user friendly and quicker way of reading the Filter Selection Cards.

    1. So, just curious why you would use “No Selection” as opposed to “All ….” as your alternate such that the value under Employee Sales Region would read “All Sales Regions”, Employee Team Name, “All Teams”. That is more specific to the information being displayed.

      1. Customer request was to have the display be no selection. It’s really a matter of preference. But yes, All would more closely match the All displayed in the slicer.

    2. You could certainly easily do that using a concatenate function in the DAX. The biggest reason was all that text wouldn’t have easily fit on a single line using the multi card visual.

  2. Hi Reid,

    I’m trying to understand the logic behind your post and am a little confused regarding the Filter Issue Number One. You show the following DAX measure:

    Employee Sales Region Selection = IF( ISFILTERED(‘Employee Details'[Sales Region]), SELECTEDVALUE(‘Employee Details'[Sales Region], “No Selection”), “No Selection”)

    The only column referenced here is ‘Employee Details'[Sales Region]’ shouldn’t that be something like ”Employee Details'[Sales Team]’ and the name be ‘ Employee Sales Team Selection ‘ instead or am I missing something here? I mean SELECTEDVALUE(‘Employee Details'[Sales Region] … can’t possibly reflect the selection of values on the sales team slicer.

    Best regards Jes

    1. Ah good catch! The logic remains the same, however you’re right. It should be the team name column. I updated to have it reflect that.

  3. Great post – thanks Reid.

    Just to confirm.. SELECTEDVALUE can only refer to Page level filters and not Report level filters? I believe the PBI development team is working on the option for Slicers to be applied (connected) to multiple reports as in Excel.

    1. Hi James, that’s “currently” correct. However we’re about to do a post VERY SOON about the universal slicer feature that is about to be released. Making this post even more relevant!

      1. Hi Reid, thanks. As luck would have it Microsoft announced the completion of the universal slicer feature yesterday. I look forward to your associated post.

  4. Hi Reid, Thank you very much. Great Article. Only one thing I can’t figure out is how you were able to get the selections to display horizontally in the multi-row card visual. I have both Card Title and Card in my format section of the visual where you have just Card. Any thoughts?

  5. Thanks for this interesting and helpful post! I like the Visual of the “Total Orders by Year, Quarter and Employee name”. What’s the name of this Visual in Power BI ? Where can I download this visual ? I searched in the Microsoft Power BI visual marketplace but didn’t find it 🙁

  6. Hi, I down loaded the workbook file to follow along as suggested in the article. Once it was unzipped there were no file associations attached to any of the files!!

    Was this meant to be this way or is there something I am missing??

    thanks ahead of time 🙂

    1. Hi Bryan, for some reason that file downloads as a .zip instead of a .pbix. If you change the file extension to this, it will open in Power BI Desktop

    1. Can we dynamically display the visualization based on this function? My requirement is let say we have sales and GP. Based on the selection I want to display either sales or GP.

  7. Excellent article,but I have a question.How does the line chart in your solution, including forecasting.Thanks

  8. Thanks for the great article, Reid. I am having a small issue when using this function for a slight variation in purpose. I used SelectedValue to show me the bar selected in a bar graph for monthly data but it does not work as soon as the drill down mode is turned on. My main purpose was to show which month is being drilled down into. Any suggestions for this? Thanks!

Leave a Comment or Question