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
ajinkyacgaikwad
Advocate I
Advocate I

Add calculated row in power query

I have a data looks like following table.
I want to have a row that will give me entry for "Remaining Countries" for all the Dates  = "World" - (All the countries)

 

CountryDateValue

India01-01-20205
China01-01-202010
Bhutan01-01-20201
India01-01-20216
China01-01-202112
Bhutan01-01-20213
World01-01-202050
World01-01-202160

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ajinkyacgaikwad  ,

 

You can input the following code in “Advanced Editor”

 

let

    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8sxLyUxU0lEyMNQFIiMDIwMgx1QpVidayTkjMw9DytAALOeUUVqSmIchCZbDMNIQyDHDbiRIytAIh5EgSWOwXHh+UU4KhisNsMuBrQPKxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Country = _t, Date = _t, Value = _t]),

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Country", type text}, {"Date", type date}, {"Value", Int64.Type}}),

    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Country]), "Country", "Value"),

    #"Inserted Multiplication" = Table.AddColumn(#"Pivoted Column", "Multiplication", each [World] * [India], Int64.Type),

    #"Removed Columns" = Table.RemoveColumns(#"Inserted Multiplication",{"Multiplication"}),

    #"Added Custom" = Table.AddColumn(#"Removed Columns", "Remaining countries", each [World]-[India]-[China]-[Bhutan]),

    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Custom", {"Date"}, "Attribute", "Value")

in

    #"Unpivoted Other Columns"

 

 

The output is as follows

vxinruzhumsft_0-1669172027287.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Xinru Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @ajinkyacgaikwad  ,

 

You can input the following code in “Advanced Editor”

 

let

    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8sxLyUxU0lEyMNQFIiMDIwMgx1QpVidayTkjMw9DytAALOeUUVqSmIchCZbDMNIQyDHDbiRIytAIh5EgSWOwXHh+UU4KhisNsMuBrQPKxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Country = _t, Date = _t, Value = _t]),

    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Country", type text}, {"Date", type date}, {"Value", Int64.Type}}),

    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Country]), "Country", "Value"),

    #"Inserted Multiplication" = Table.AddColumn(#"Pivoted Column", "Multiplication", each [World] * [India], Int64.Type),

    #"Removed Columns" = Table.RemoveColumns(#"Inserted Multiplication",{"Multiplication"}),

    #"Added Custom" = Table.AddColumn(#"Removed Columns", "Remaining countries", each [World]-[India]-[China]-[Bhutan]),

    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Custom", {"Date"}, "Attribute", "Value")

in

    #"Unpivoted Other Columns"

 

 

The output is as follows

vxinruzhumsft_0-1669172027287.png

 

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Xinru Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ryan_mayu
Super User
Super User

@ajinkyacgaikwad 

you can try to use DAX to create a new table

Table 2 = 
VAR tbl=ADDCOLUMNS( SUMMARIZE('Table','Table'[date],"value",sumx(FILTER('Table','Table'[Country]="World"),'Table'[value])-sumx(FILTER('Table','Table'[Country]<>"World"),'Table'[value])),"Country","Remaining Countries")
var tbl2=SELECTCOLUMNS(tbl,"Country",[Country],"date",'Table'[date],"value",[value])
return UNION('Table',tbl2)

1.PNG





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

Proud to be a Super User!




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.