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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
iamriz
Helper II
Helper II

How to create a line chart with a number of lines equal to the number of items selected in slicer?

Hello everyone,

Is it possible to create a single line chart equal to the number of items selected in a slicer?

 

Sample scenario is I have a product slicer where users can select more than 1 products.

Goal is to create a single line chart with multiple lines plotted equal to the number of products selected on the slicer.

X-axis will be dates, while y-axis would be an aggregate value of sales.

So if there are 4 products selected, there should be 4 lines on the line chart.

 

Kindly advise an approach on how to do this quickly. Right now, I am trying to achieve this through Python visual but having a hard time doing so. Any feedback will be much appreciated, thank you.

4 REPLIES 4
TomMartens
Super User
Super User

Hey @iamriz ,

 

this then will become more complex 😉

 

You have to adapt the solution that is described here to your needs: Show previous 6 months of data from single slicer selection - SQLBI

 

Hopefully, this provides you with an idea on how you can tackle your challenge.

 

Regards,

Tom

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
TomMartens
Super User
Super User

Hey @iamriz ,

 

not sure if I understand your requirment correctly,  but this can be achieved using the Power BI line chart, simple drag the column that feeds the slicer also to the legend bucket of the line chart:

image.png

Not sure why you want to do this with python.

Hopefully, this provides an idea of how to tackle your challenge.

Regards,
Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi @TomMartens , thanks for your response. Very much appreciated. Indeed, your suggestion is correct. However, I lacked a detail to the scenario I mentioned. Basically, the x-axis values are just fixed values (not really the date as I originally mentioned in my post). This fixed values (0 to 6) represents the dynamic period as to which the aggregate of sales would be computed per Product.

 

Chart would look something like this:

 

Y-axis (sales)

10

9

...

2

1

0   1    2   3   4   5   6  = X-axis (fixed values)

 

If user inputs date = 5/8/2022 on a date slicer;

If x=6, the measure will return the sales 1 week ago from the date inputted (period of 5/2 to 5/8/2022);

If x=5, the measure will return the sales 2 weeks ago from the date inputted (period of 4/25 to 5/1/2022);

and so on, up until 6 weeks ago of weekly sales.

 

If I select a single product from the Product slicer, the measure will correctly be plotted in one line on the line chart above. However, if more than one is selected on the product slicer, the line chart will just show me one flat line on the 0 y-axis for some reason I don't know yet.

 

Hi @iamriz ,

According to your description, I think it relates to the formula of the Values in your line chart. You can try to change the line chart to a table visual to see if it can get the correct result when you select two products. Or you can provide more detailed sample data for further help.

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.