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
nTuomo
New Member

Filter to line chart?

Hi!

 

I need a line chart that only shows filtered data. User could use a filter and select the data they want to be seen in the line chart.

Here is my data (excel):

 

nTuomo_0-1730715616673.png

 

Here is the line chart:

 

nTuomo_1-1730715926660.png

nTuomo_2-1730715955576.png

 

Here is the filter - how should I build it?

 

nTuomo_3-1730715997085.png

nTuomo_4-1730716009622.png

 

Many thanks!

Tuomo, Finland

 

 

1 ACCEPTED SOLUTION

Hi @nTuomo ,

 

I suggest you to create a Dim column header table to help calculation.

Dim data column header = 
DATATABLE(
    "data column",STRING,
    "Order",INTEGER,
    {
        {"data 1",1},
        {"data 2",2},
        {"data 3",3},
        {"data 4",4},
        {"data 5",5}
    }
)

Measure:

Measure = 
VAR _data1 = SUM('Table'[data 1])
VAR _data2 = SUM('Table'[data 2])
VAR _data3 = SUM('Table'[data 3])
VAR _data4 = SUM('Table'[data 4])
VAR _data5 = SUM('Table'[data 5])
RETURN
SWITCH(SELECTEDVALUE('Dim data column header'[Order]),1,_data1,2,_data2,3,_data3,4,_data4,5,_data5)

Result is as below.

vrzhoumsft_2-1730791699502.png

vrzhoumsft_3-1730791709429.png

 

Or you can Unpivot other columns by [year] in Power Query Editor to do some transformation on your table.

vrzhoumsft_4-1730791811771.png

vrzhoumsft_5-1730791825189.png

Then it will be easier to achieve your goal, you can add [Value] in Y axis and [Attribute] in Legend.

vrzhoumsft_6-1730791915609.png

For reference: Unpivot columns - Power Query | Microsoft Learn

 

Best Regards,
Rico Zhou

 

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

3 REPLIES 3
nTuomo
New Member

@saipranay Thank you for the reply!

But how could I get the filter to work so that user can select, which data is visible on line chart?

Selection should be between Data 1 / Data 2 / Data 3 ... etc

Not the way it is now (2 / 8 / 9 etc...) : 

nTuomo_0-1730719049154.png

 

Hi @nTuomo ,

 

I suggest you to create a Dim column header table to help calculation.

Dim data column header = 
DATATABLE(
    "data column",STRING,
    "Order",INTEGER,
    {
        {"data 1",1},
        {"data 2",2},
        {"data 3",3},
        {"data 4",4},
        {"data 5",5}
    }
)

Measure:

Measure = 
VAR _data1 = SUM('Table'[data 1])
VAR _data2 = SUM('Table'[data 2])
VAR _data3 = SUM('Table'[data 3])
VAR _data4 = SUM('Table'[data 4])
VAR _data5 = SUM('Table'[data 5])
RETURN
SWITCH(SELECTEDVALUE('Dim data column header'[Order]),1,_data1,2,_data2,3,_data3,4,_data4,5,_data5)

Result is as below.

vrzhoumsft_2-1730791699502.png

vrzhoumsft_3-1730791709429.png

 

Or you can Unpivot other columns by [year] in Power Query Editor to do some transformation on your table.

vrzhoumsft_4-1730791811771.png

vrzhoumsft_5-1730791825189.png

Then it will be easier to achieve your goal, you can add [Value] in Y axis and [Attribute] in Legend.

vrzhoumsft_6-1730791915609.png

For reference: Unpivot columns - Power Query | Microsoft Learn

 

Best Regards,
Rico Zhou

 

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

saipranay
Regular Visitor

Hello @nTuomo ,
As per your stated question, In Visualization tab we can use slicer visual to get the functionality you are looking for. 

saipranay_0-1730717341709.png

 

saipranay_1-1730717379554.png Use this as a visual for your report buliding.

 

saipranay_2-1730717643703.png

By following above steps you can get our fliter option which you are looking for.
For addition help: 

Customize the Visualization pane in Power BI Desktop and the Power BI service - Power BI | Microsoft...
Thank you

 

 

 

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.