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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
AntonioTG
New Member

Line chart slicer

Hello, I am new creating Power BI reports, my apologies if my question sounds stupid.

I am trying to add a line chart tile with 3 lines, that are shown by default. That is "Value1", "Value2" and "Value3" (that have a time series) are added to "Value" field of the LineChart.

I would like to select one of those three lines, so that the diagram shows only the selected one.

Can I add any kind of slicer with 3 elements (Value1, Value2 and Value3), so that when one of those three elements is selected, the drawing is automatically updated with only the line with the values of the selected time series?.

Now, when I add a slicer to the report and add the "ValueX" to the Field of the slicer, all the values are shown. And I do not want this.

Thank you very much!!

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @AntonioTG,

 

If I understanding correctly, the line chart displays three lines by default without any selection, and if you select a specific value from slicer, this chart should be automatically updated with only the line based on selection.

 

Below is my test, please review it.

 

Create an extra table which includes one column to list the available selections in slicer.
1.PNG

 

Create three measures that will be added into "Value" field of the LineChart. You should change the column name ('total per row[expected]', 'total per row[atual]', 'total per row[Amount]') according to your own scenario.

Value1 =
IF (
    LASTNONBLANK ( 'Select'[Select], 1 ) = "Value1",
    LASTNONBLANK ( 'total per row'[expected], 1 ),
    IF (
        ISFILTERED ( 'Select'[Select] ) = FALSE (),
        LASTNONBLANK ( 'total per row'[expected], 1 ),
        BLANK ()
    )
)

Value2 =
IF (
    LASTNONBLANK ( 'Select'[Select], 1 ) = "Value2",
    LASTNONBLANK ( 'total per row'[atual], 1 ),
    IF (
        ISFILTERED ( 'Select'[Select] ) = FALSE (),
        LASTNONBLANK ( 'total per row'[atual], 1 ),
        BLANK ()
    )
)

Value3 =
IF (
    LASTNONBLANK ( 'Select'[Select], 1 ) = "Value3",
    LASTNONBLANK ( 'total per row'[Amount], 1 ),
    IF (
        ISFILTERED ( 'Select'[Select] ) = FALSE (),
        LASTNONBLANK ( 'total per row'[Amount], 1 ),
        BLANK ()
    )
)

I can get the expect line if I select "Value2".

2.PNG3.PNG

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

13 REPLIES 13
sabirguiri
Frequent Visitor

That's what everyone has been asking for with multiple selection. You will be prompted to create a dax table for each selection.

https://sqlskull.com/2020/10/17/show-hide-measures-in-line-chart-visuals-using-slicer-in-power-bi/

timfrikkee
Frequent Visitor

Could anyone please expand on the possibility of selecting multiple measures in a visual using the above-explained approach?

 

The most recent answer to the multiple selection question referred to the properties pane which is to my understanding no longer available in the current PBI desktop version. 

As i was passing by this topic for my own interest, i encountered the same issue and was able to find a solution, here is what you were looking for  : 

 

 

Value1 =
IF (
    LASTNONBLANK ( 'Select'[Select], 1 ) = "Value1",
    LASTNONBLANK ( 'total per row'[expected], 1 ),
    IF (
        CONTAINS(ALLSELECTED('Select'[Select]), [Select], "Value1"),
        LASTNONBLANK ( 'total per row'[expected], 1 ),
        BLANK ()
    )
)

 

 

This will allow for multiple selections.

v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @AntonioTG,

 

If I understanding correctly, the line chart displays three lines by default without any selection, and if you select a specific value from slicer, this chart should be automatically updated with only the line based on selection.

 

Below is my test, please review it.

 

Create an extra table which includes one column to list the available selections in slicer.
1.PNG

 

Create three measures that will be added into "Value" field of the LineChart. You should change the column name ('total per row[expected]', 'total per row[atual]', 'total per row[Amount]') according to your own scenario.

Value1 =
IF (
    LASTNONBLANK ( 'Select'[Select], 1 ) = "Value1",
    LASTNONBLANK ( 'total per row'[expected], 1 ),
    IF (
        ISFILTERED ( 'Select'[Select] ) = FALSE (),
        LASTNONBLANK ( 'total per row'[expected], 1 ),
        BLANK ()
    )
)

Value2 =
IF (
    LASTNONBLANK ( 'Select'[Select], 1 ) = "Value2",
    LASTNONBLANK ( 'total per row'[atual], 1 ),
    IF (
        ISFILTERED ( 'Select'[Select] ) = FALSE (),
        LASTNONBLANK ( 'total per row'[atual], 1 ),
        BLANK ()
    )
)

Value3 =
IF (
    LASTNONBLANK ( 'Select'[Select], 1 ) = "Value3",
    LASTNONBLANK ( 'total per row'[Amount], 1 ),
    IF (
        ISFILTERED ( 'Select'[Select] ) = FALSE (),
        LASTNONBLANK ( 'total per row'[Amount], 1 ),
        BLANK ()
    )
)

I can get the expect line if I select "Value2".

2.PNG3.PNG

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

 

Hi @v-yulgu-msft

 

Thank for your solution!

I was wondering how you could change the formula in order to allow multiple selections.

Since I am now only able to select one line at the time.

 

Thanks!

Anonymous
Not applicable

Am I able to select multile slicers items instead of just one at a time?

Yes you can hold down the CTRL button and then click with your mouse to select multiple items.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Anonymous
Not applicable

Thanks , no I want to use a slicer which will have multiple selections just like explained above in the answer, currently it just enables one selection.I want that for multiple selection.

You can change it in the properties pane.




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Anonymous
Not applicable

Sorry if I may not be clear, if you consider the solution provided above, that allows for only one selection whether I chnage the setting on the slicer to multiple select or single select. I want to be able to do multi select from the option above.

Hi

 

Thanks for the post, it is very helpful!

However, as I dont fully understand the code as I am uncertain about what the second line ('total per row' [expected],1) means. I believe that this is a column, but is not 'Value 1' only consiting of one column  -->LASTNONBLANK ( 'total per row'[expected], 1 )? What is the purpose of LASTNONBLANK ( 'Select'[Select], 1 ) ?

 

Kind regards,

GilbertQ
Super User
Super User

Hi @AntonioTG

 

If I understand that you are trying to do is using a Disconnected Slicer.

 

Where when you select a measure that is part of the disconnected slicer, it will then display what you select in your chart?

 

Is that when you are after?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

Greg_Deckler
Super User
Super User

I'm not aware of a way to do what you are asking.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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