Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
Anonymous
Not applicable

When all is selected or multiple values are selected in slicer, show nothing in line chart

Hi All,

 

We have below requirement in Power BI where Line chart should display data only in the case of single selection value in slicer. Please go through below cases:

 

When All is selected in slicer, Power BI Line chart should display empty.

When Multiple values are selected in above slicer, Power BI Line chart should display empty.

When single value is selected in above slicer, Chart should display corressponding data.

 

We are using Analysis services Live connection and we also need to keep multiple selections as enabled in slicer properties. Please let us know if we can accomplish this using DAX or by some other workaround.

1 ACCEPTED SOLUTION
wynhopkins
Most Valuable Professional
Most Valuable Professional

Yep, all good with HASONEFILTER 

MVP | Author of Power BI for the Excel Analyst | Speaker | Power BI & Excel Developer & Instructor | YouTube- 5 million views | Fan of Power Query & XLOOKUP | Purpose: Making life easier for people through applying and sharing knowledge.

View solution in original post

9 REPLIES 9
wynhopkins
Most Valuable Professional
Most Valuable Professional

Could you use

  =IF(
 HASONEVALUE (SlicerTable[SlicerColumn] ),
            [Measure],
            BLANK()
)
MVP | Author of Power BI for the Excel Analyst | Speaker | Power BI & Excel Developer & Instructor | YouTube- 5 million views | Fan of Power Query & XLOOKUP | Purpose: Making life easier for people through applying and sharing knowledge.

So, this looks interesting, but where does it go? Is this a measure? Do you add it to the table? How do you actually implement it? 

wynhopkins
Most Valuable Professional
Most Valuable Professional

Hi, it's a measure that replaces the one that would have been in your chart

MVP | Author of Power BI for the Excel Analyst | Speaker | Power BI & Excel Developer & Instructor | YouTube- 5 million views | Fan of Power Query & XLOOKUP | Purpose: Making life easier for people through applying and sharing knowledge.

Maybe I need to put in a new question. I have a table with some milestones across the top (x-axis), and organizations in the first column (x-axis). I have a slicer that allows me to select organizations, and then some cards display dates of achievement of the milestones. If I have selected none, or all, I would like the cards to all just display blanks. 

wynhopkins
Most Valuable Professional
Most Valuable Professional

Yes, probably best in future to post new thread (referencing this one) rather than adding to a solved one.
You would need to edit each measure in each card visual to be something like this,  where the Slicer Table Slicer Column are your OrganisationTable[Org Name] that you are using in your slicer

  =IF(
 HASONEFILTER(SlicerTable[SlicerColumn] ),
            [Measure],
            BLANK()
)

 

 

 

 

MVP | Author of Power BI for the Excel Analyst | Speaker | Power BI & Excel Developer & Instructor | YouTube- 5 million views | Fan of Power Query & XLOOKUP | Purpose: Making life easier for people through applying and sharing knowledge.
Anonymous
Not applicable

@wynhopkins 

 

I already tried this, but as per my understanding HASONEVALUE() on the basis of distinct values. But as it's a live connection to analysis servcies, there are many duplicate Job names for all the employees so HASONEVALUE function is returning data in chart in case of ALL is selected in slicer.

 

I have also tried HASONEFILTER() and this is working fine. I wanna double check in this case as I haven't used HASONEFILTER() previously. I just need to show data in case of single value in slicer is selected. Please update me with your suggestions if I am on a wrong track.

jdbuchanan71
Super User
Super User

Hello @Anonymous 

You can accomplish this using something like the following.  In the measure below, the value I want to display is [Total Budget] but only if a single Dates[Year Month] is selected.

Amount Filtered = 
VAR SlicerSelection = SELECTEDVALUE( Dates[Year Month] )
RETURN 
IF ( NOT ISBLANK ( SlicerSelection ), [Total budget] )

VAR SlicerSelection = SELECTEDVALUE( Dates[Year Month] ) reads the selection of the Date[Year Month] column and returns a result only if a single month is selected.  If more that one month is selected (including all months) SELECTEDVALUE( Dates[Year Month] ) returns BLANK.  Then we check if our VAR is not blank, meaning a single month is selected, and if so return the [Total Budget] measure, otherwise return BLANK.

Anonymous
Not applicable

@jdbuchanan71 

 

I already tried this. But as it's a live connection to analysis servcies, there are many duplicate Job names for all the employees so your above DAX is returning data in chart in case of ALL or multiple values are selected in slicer.

 

I have also tried HASONEFILTER() and this is working fine. I wanna double check in this case as I haven't used HASONEFILTER() previously. I just need to show data in case of single value in slicer is selected. Please update me with your suggestions if I am on a wrong track.

wynhopkins
Most Valuable Professional
Most Valuable Professional

Yep, all good with HASONEFILTER 

MVP | Author of Power BI for the Excel Analyst | Speaker | Power BI & Excel Developer & Instructor | YouTube- 5 million views | Fan of Power Query & XLOOKUP | Purpose: Making life easier for people through applying and sharing knowledge.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.