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
vynguyen
Frequent Visitor

How to create Calculated table?

Current table:

vynguyen_1-1715942882999.png

I want my table to look like the one below, what formula should I use?

vynguyen_2-1715942915941.png

Tks

1 ACCEPTED SOLUTION
nandic
Super User
Super User

@vynguyen 
Here is Power Query solution which you can paste in advanced editor, just use your source.
Or take step by step.

Here are steps:
1) in power query select column State > Transform > unpivot other columns

nandic_1-1715943613900.png

 


2) rename collumn "Attribute" to "Product"

nandic_2-1715943633226.png

 


3) go to Transform > Group By and add these settings:

nandic_0-1715943575047.png

 

4) Last, filter out if value = 0

nandic_3-1715943664745.png

 

Result:

nandic_4-1715943750813.png

 




let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIEYgOlWJ1oJScwS0fJCMxDlXOEyhkqxcYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [State = _t, #"Product 1" = _t, #"Product 2" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"State", type text}, {"Product 1", Int64.Type}, {"Product 2", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"State"}, "Attribute", "Value"),
#"Renamed Columns" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Product"}}),
#"Grouped Rows" = Table.Group(#"Renamed Columns", {"State", "Product"}, {{"Quantity", each List.Sum([Value]), type number}}),
#"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each ([Quantity] <> 0))
in
#"Filtered Rows"

Cheers,
Nemanja Andic

View solution in original post

2 REPLIES 2
vynguyen
Frequent Visitor

Tks

nandic
Super User
Super User

@vynguyen 
Here is Power Query solution which you can paste in advanced editor, just use your source.
Or take step by step.

Here are steps:
1) in power query select column State > Transform > unpivot other columns

nandic_1-1715943613900.png

 


2) rename collumn "Attribute" to "Product"

nandic_2-1715943633226.png

 


3) go to Transform > Group By and add these settings:

nandic_0-1715943575047.png

 

4) Last, filter out if value = 0

nandic_3-1715943664745.png

 

Result:

nandic_4-1715943750813.png

 




let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclTSUTIEYgOlWJ1oJScwS0fJCMxDlXOEyhkqxcYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [State = _t, #"Product 1" = _t, #"Product 2" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"State", type text}, {"Product 1", Int64.Type}, {"Product 2", Int64.Type}}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"State"}, "Attribute", "Value"),
#"Renamed Columns" = Table.RenameColumns(#"Unpivoted Other Columns",{{"Attribute", "Product"}}),
#"Grouped Rows" = Table.Group(#"Renamed Columns", {"State", "Product"}, {{"Quantity", each List.Sum([Value]), type number}}),
#"Filtered Rows" = Table.SelectRows(#"Grouped Rows", each ([Quantity] <> 0))
in
#"Filtered Rows"

Cheers,
Nemanja Andic

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.

Top Solution Authors