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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
JohnJoe123
Helper II
Helper II

How to build a Slicer for the Lines on a 'Line & Clustered Column' Chart?

Hi Everyone,

 

Here is a Link to my Power BI File via Google Drive:

https://drive.google.com/file/d/1F13hFYYGtAjgbcwYLvx-97YfM8MXfDDd/view?usp=drive_link

 

So, I have built a Line & Clustered Column Chart with the Data from my Power BI Query.

An image of said Chart is shown below.

 

I currently have 3 Lines on this Graph - Called Line A, Line B and Line C.

(Red, Green & Pink Lines Respectively)

JohnJoe123_1-1715269087713.png

 

My Question is: 

Is is Possible to Build a Slicer which can Toggle these Lines On & Off on the Graph?

 

I'd like Something like the Week Number Slicer that I currently have in my Power BI File.

So the final Result would be something like this: (I made the below image in Power Point)

JohnJoe123_0-1715269047967.png

 

 

2 ACCEPTED SOLUTIONS
v-huijiey-msft
Community Support
Community Support

Hi @JohnJoe123 ,

 

Yes, you can do it.

 

Firstly, create a table contain all lines’ name:

Lines

Line A

Line B

Line C

 

I noticed that the aggregation method of your lines is Average. Therefore, create a measure to store three lines for calling in the newly created table:

_Line A = AVERAGE('D - ISP'[Line A])

_Line B = AVERAGE('D - ISP'[Line B])

_Line C = AVERAGE('D - ISP'[Line C])

 

Drag the Lines field of the new table into the Slicer:

vhuijieymsft_0-1715324246408.png

 

Create a measure:

Measure = SWITCH(TRUE(),
SELECTEDVALUE(Lines[Lines]) = "line A", 'D - ISP'[_Line A],
SELECTEDVALUE(Lines[Lines]) = "line B", 'D - ISP'[_Line B],
SELECTEDVALUE(Lines[Lines]) = "line C", 'D - ISP'[_Line C]
)

 

Place measure on the Line y-axis of the chart, and the final page effect is as shown below:

vhuijieymsft_1-1715324246413.png

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

Hi @JohnJoe123 ,

 

Please try:

 

Modify the measure syntax as follows:

_Line A = IF(ISFILTERED('Lines'[Lines]),IF("Line A"IN VALUES(Lines[Lines]),AVERAGE('D - ISP'[Line A])),BLANK())

_Line B = IF(ISFILTERED('Lines'[Lines]),IF("Line B"IN VALUES(Lines[Lines]),AVERAGE('D - ISP'[Line B])),BLANK())

_Line C = IF(ISFILTERED('Lines'[Lines]),IF("Line C"IN VALUES(Lines[Lines]),AVERAGE('D - ISP'[Line C])),BLANK())

 

Other operations remain unchanged, and the page effect is as shown below:

vhuijieymsft_0-1716258712789.png
vhuijieymsft_1-1716258712792.png

vhuijieymsft_2-1716258769874.png

vhuijieymsft_3-1716258769880.png

vhuijieymsft_4-1716258778809.png

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

6 REPLIES 6
v-huijiey-msft
Community Support
Community Support

Hi @JohnJoe123 ,

 

Yes, you can do it.

 

Firstly, create a table contain all lines’ name:

Lines

Line A

Line B

Line C

 

I noticed that the aggregation method of your lines is Average. Therefore, create a measure to store three lines for calling in the newly created table:

_Line A = AVERAGE('D - ISP'[Line A])

_Line B = AVERAGE('D - ISP'[Line B])

_Line C = AVERAGE('D - ISP'[Line C])

 

Drag the Lines field of the new table into the Slicer:

vhuijieymsft_0-1715324246408.png

 

Create a measure:

Measure = SWITCH(TRUE(),
SELECTEDVALUE(Lines[Lines]) = "line A", 'D - ISP'[_Line A],
SELECTEDVALUE(Lines[Lines]) = "line B", 'D - ISP'[_Line B],
SELECTEDVALUE(Lines[Lines]) = "line C", 'D - ISP'[_Line C]
)

 

Place measure on the Line y-axis of the chart, and the final page effect is as shown below:

vhuijieymsft_1-1715324246413.png

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Hi,

Sorry for just responding now!

Thank you so much for this!

Maybe I seem pedantic, but there is one small issue with your Solution.

When I click on just one Line in the newly created Slicer - it displays the selected Line no problem.

But if I select multiple Lines - it does not show any of them.

 

I'd like the Slicer to work such that I could select all 3 Lines at once, and that they would then all be visible on the graph at once. (And also I'd like it that each Line would still have a different Colour - like the Red, Green and Pink in my Original Image)

 

Is this Possible?

Hi @JohnJoe123 ,

 

Modify these three measures:

_Line A = IF("Line A"IN VALUES(Lines[Lines]),AVERAGE('D - ISP'[Line A]))

_Line B = IF("Line B"IN VALUES(Lines[Lines]),AVERAGE('D - ISP'[Line B]))

_Line C = IF("Line C"IN VALUES(Lines[Lines]),AVERAGE('D - ISP'[Line C]))

 

Put these three measures into the Line y axis, and the page effect is as follows:

vhuijieymsft_0-1715935580854.png

vhuijieymsft_1-1715935580860.png

vhuijieymsft_2-1715935595733.png

vhuijieymsft_3-1715935595743.png

 

The pbix file has been attached, if you have any other questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Thank you!

Just one more thing:

Is it possible to preserve the graph's current functionality - while also adding another feature?

This other feature being:

 

Is it possible to make all 3 Lines Disappear / Invisible - when NONE of them are Selected in the Relevant Slicer?

Hi @JohnJoe123 ,

 

Please try:

 

Modify the measure syntax as follows:

_Line A = IF(ISFILTERED('Lines'[Lines]),IF("Line A"IN VALUES(Lines[Lines]),AVERAGE('D - ISP'[Line A])),BLANK())

_Line B = IF(ISFILTERED('Lines'[Lines]),IF("Line B"IN VALUES(Lines[Lines]),AVERAGE('D - ISP'[Line B])),BLANK())

_Line C = IF(ISFILTERED('Lines'[Lines]),IF("Line C"IN VALUES(Lines[Lines]),AVERAGE('D - ISP'[Line C])),BLANK())

 

Other operations remain unchanged, and the page effect is as shown below:

vhuijieymsft_0-1716258712789.png
vhuijieymsft_1-1716258712792.png

vhuijieymsft_2-1716258769874.png

vhuijieymsft_3-1716258769880.png

vhuijieymsft_4-1716258778809.png

 

pbix file is attached.

 

If you have any further questions please feel free to contact me.

 

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Thank you so much for this!

It is working perfectly for me now! 🙂

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.