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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
lf963
Frequent Visitor

Line chart with special data

My data is an xlsx file and it looks like the following:

 Name  Day1  Day2  Day3  Day4  Day5 
A51867
B18725
C47520
D85562

 

The value of A at Day1 is 5; the value of C at Day4 is 2 and so on.

 

My requirements are the following:

  1. Use 4 lines in one single line chart to show the trends for A, B, C and D.
  2. I can use a filter to show or hide any line.

The following image is what I need.

  1. requirement.png

 

 

If I transpose my data like the following, it's easy to create the line chart but I couldn't filter out the line. For example, I cannot hide A and C just like the above image.

 

 Day BCD
 Day1 5148
 Day2 1875
 Day3 8755
 Day4 6226
 Day5 7502

 

Thanks

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Unpivot your data.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIFYkMgtgBiMyA2V4rViVZyQhI1B2IjsEqQjDOQZQIVNYXKGIBlXKDqTaHYDCwbGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Name " = _t, #" Day1 " = _t, #" Day2 " = _t, #" Day3 " = _t, #" Day4 " = _t, #" Day5 " = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Name "}, "Day", "Value"),
    #"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Value", type number}})
in
    #"Changed Type"

 

Then everything else works automatically.

 

lbendlin_0-1689470323377.png

 

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

Unpivot your data.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIFYkMgtgBiMyA2V4rViVZyQhI1B2IjsEqQjDOQZQIVNYXKGIBlXKDqTaHYDCwbGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Name " = _t, #" Day1 " = _t, #" Day2 " = _t, #" Day3 " = _t, #" Day4 " = _t, #" Day5 " = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"Name "}, "Day", "Value"),
    #"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Value", type number}})
in
    #"Changed Type"

 

Then everything else works automatically.

 

lbendlin_0-1689470323377.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.