Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
94 | |
82 | |
66 | |
58 |
User | Count |
---|---|
151 | |
121 | |
104 | |
87 | |
67 |