Don't miss your chance to take exam DP-600 or DP-700 on us!
Request nowLearn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
I would like to create a line graph using an excel data source. The issue is the excel has seperate columns for each year and therefore I do not know an easy way to use these seperate fields in one line graph. I have attached a screenshot of the data below:
We also have a field for the average ages of buyers for that region.
Solved! Go to Solution.
@dswallow , Unpivot the data in the power query.
Unpivot Data(Power Query): https://youtu.be/2HjkBtxSM0g
If need you can take a year as a legend in the line visual post that
Hi @dswallow ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) Click "Transform Data" to enter the Power Query editor and select three columns to transpose.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRQ0lEK9QYSJkBsqoqFEasTrWQOZLqWFuUXpAIZxkBspoqFAVJpBGQGOwIJI5gx6AyQKkOQrWBlIK3mIFlDNEZsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Avg <5>" = _t, Region = _t, #"2022" = _t, #"2022%" = _t, #"2021" = _t, #"2021%" = _t, #"2020" = _t, #"2020%" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Avg <5>", Int64.Type}, {"Region", type text}, {"2022", Int64.Type}, {"2022%", Percentage.Type}, {"2021", Int64.Type}, {"2021%", Percentage.Type}, {"2020", Int64.Type}, {"2020%", Percentage.Type}}),
#"Unpivoted Only Selected Columns" = Table.Unpivot(#"Changed Type", {"2022", "2021", "2020"}, "Attribute", "Value"),
#"Renamed Columns" = Table.RenameColumns(#"Unpivoted Only Selected Columns",{{"Attribute", "Year"}, {"Value", "Sales"}})
in
#"Renamed Columns"
(3) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @dswallow ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) Click "Transform Data" to enter the Power Query editor and select three columns to transpose.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRQ0lEK9QYSJkBsqoqFEasTrWQOZLqWFuUXpAIZxkBspoqFAVJpBGQGOwIJI5gx6AyQKkOQrWBlIK3mIFlDNEZsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Avg <5>" = _t, Region = _t, #"2022" = _t, #"2022%" = _t, #"2021" = _t, #"2021%" = _t, #"2020" = _t, #"2020%" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Avg <5>", Int64.Type}, {"Region", type text}, {"2022", Int64.Type}, {"2022%", Percentage.Type}, {"2021", Int64.Type}, {"2021%", Percentage.Type}, {"2020", Int64.Type}, {"2020%", Percentage.Type}}),
#"Unpivoted Only Selected Columns" = Table.Unpivot(#"Changed Type", {"2022", "2021", "2020"}, "Attribute", "Value"),
#"Renamed Columns" = Table.RenameColumns(#"Unpivoted Only Selected Columns",{{"Attribute", "Year"}, {"Value", "Sales"}})
in
#"Renamed Columns"
(3) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@dswallow , Unpivot the data in the power query.
Unpivot Data(Power Query): https://youtu.be/2HjkBtxSM0g
If need you can take a year as a legend in the line visual post that
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 51 | |
| 40 | |
| 37 | |
| 14 | |
| 14 |
| User | Count |
|---|---|
| 85 | |
| 69 | |
| 38 | |
| 29 | |
| 27 |