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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
zachtatum
Frequent Visitor

table to bar chart

I'm confused about how to reorganize this data. 

 

I would like to show a bar chart. Each bar is a year, and shows the total GRAC contribution from the projects. I suspect that I need to create a virtual table...

 

x-axis = year

y-axis = sum of GRAC for that year

 

Here's what my data looks like.

 

ProjectNameGRaC 2023GRaC 2024GRaC 2025GRaC 2026GRaC 2027GRaC 2028
project apple2.152.493.031.22  
project orange03.456.977.53  
project bananna 0.753.23.823.82 
project watermelon 7.819.6310.290.29 
project tangerine 0.646.586.624.9 
2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

First step is to unpivot the data to bring it into a usable form

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bY7LCgIxDEV/Zeh6CH0/vmWYRZQiytiWUvD3bUNRB1wkZ5Gc5G4bKzU/4rUtWMoR2cokCEPQoUMBVx0CpOxYqPb1a+WK6TY0Tst6qBaC63Bg1F/ngglTwjnj4Ay5krr/wVl7YYv1GY+cpunAi44AliJykIHuEc5uGynrPcXPU6spqfEEO95pmOL+Bg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ProjectName = _t, #"GRaC 2023" = _t, #"GRaC 2024" = _t, #"GRaC 2025" = _t, #"GRaC 2026" = _t, #"GRaC 2027" = _t, #"GRaC 2028" = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"ProjectName"}, "Attribute", "Value"),
    #"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Value", Currency.Type}})
in
    #"Changed Type"

 

Then the visual writes itself.

 

lbendlin_0-1685828927100.png

 

View solution in original post

Yes, you do the unpivoting as part of the ETL in Power Query. 

View solution in original post

4 REPLIES 4
lbendlin
Super User
Super User

First step is to unpivot the data to bring it into a usable form

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bY7LCgIxDEV/Zeh6CH0/vmWYRZQiytiWUvD3bUNRB1wkZ5Gc5G4bKzU/4rUtWMoR2cokCEPQoUMBVx0CpOxYqPb1a+WK6TY0Tst6qBaC63Bg1F/ngglTwjnj4Ay5krr/wVl7YYv1GY+cpunAi44AliJykIHuEc5uGynrPcXPU6spqfEEO95pmOL+Bg==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ProjectName = _t, #"GRaC 2023" = _t, #"GRaC 2024" = _t, #"GRaC 2025" = _t, #"GRaC 2026" = _t, #"GRaC 2027" = _t, #"GRaC 2028" = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"ProjectName"}, "Attribute", "Value"),
    #"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Value", Currency.Type}})
in
    #"Changed Type"

 

Then the visual writes itself.

 

lbendlin_0-1685828927100.png

 

Thank you.

 

It worked.

 

Is there a way that I can unpivot to a new table like you propose, but also still keep the new unpivoted table synced to the source table?

Yes, you do the unpivoting as part of the ETL in Power Query. 

Got it. Thank you very much for you time helping me.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.