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
topazz11
Helper III
Helper III

adding rows?

I have a data table with current and prior data. 

Is it possible to add variance data between the two in the table or create a table together?

 

TypeNamevalue
Currentaa9
Currentbb8
Currentcc8
Currentdd9
Currentee7
Prioraa4
Priorbb5
Prioree6
Priordd7
Priorcc5
Priordd4
Varianceaa1
Variancebb3
Varianceee1
Variancecc3
Variancedd5
1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@topazz11 

you can do this in PQ

1. group by table

 

11.png

 

2. pivot table

12.png

 

3. create variance column

13.png

 

4. unpivot table

14.png

 

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCqksSFXSUfJLzAVRZYk5palKsTrRSs6lRUWpeSVAscREIGGJJpiUBCQs0ASTk7EIpqRg0Z4KsswcLBhQlJlfBLPGBEUIbIkpihBYoxmKENgCVLPADjHFanwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}}),
#"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Type", type text}, {"Name", type text}, {"value", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type1", {"Type", "Name"}, {{"value", each List.Sum([value]), type nullable number}}),
#"Pivoted Column" = Table.Pivot(#"Grouped Rows", List.Distinct(#"Grouped Rows"[Type]), "Type", "value"),
#"Added Custom" = Table.AddColumn(#"Pivoted Column", "variance", each [Current]-[Prior]),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Custom", {"Name"}, "Attribute", "Value"),
#"Sorted Rows" = Table.Sort(#"Unpivoted Other Columns",{{"Attribute", Order.Ascending}})
in
#"Sorted Rows"

 

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
ryan_mayu
Super User
Super User

@topazz11 

you can do this in PQ

1. group by table

 

11.png

 

2. pivot table

12.png

 

3. create variance column

13.png

 

4. unpivot table

14.png

 

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCqksSFXSUfJLzAVRZYk5palKsTrRSs6lRUWpeSVAscREIGGJJpiUBCQs0ASTk7EIpqRg0Z4KsswcLBhQlJlfBLPGBEUIbIkpihBYoxmKENgCVLPADjHFanwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"(blank)" = _t, #"(blank).1" = _t, #"(blank).2" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"(blank)", type text}, {"(blank).1", type text}, {"(blank).2", type text}}),
#"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
#"Changed Type1" = Table.TransformColumnTypes(#"Promoted Headers",{{"Type", type text}, {"Name", type text}, {"value", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type1", {"Type", "Name"}, {{"value", each List.Sum([value]), type nullable number}}),
#"Pivoted Column" = Table.Pivot(#"Grouped Rows", List.Distinct(#"Grouped Rows"[Type]), "Type", "value"),
#"Added Custom" = Table.AddColumn(#"Pivoted Column", "variance", each [Current]-[Prior]),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Custom", {"Name"}, "Attribute", "Value"),
#"Sorted Rows" = Table.Sort(#"Unpivoted Other Columns",{{"Attribute", Order.Ascending}})
in
#"Sorted Rows"

 

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Ashish_Excel
Super User
Super User

Hi,

Why do you want to do this?  Why not show name in the row labels, type in the column labels and variance as the last column?  Also, don't you have a date column?

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.