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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
jmuthukumaran
Frequent Visitor

insert row in the table

Team , 

I need to add a new row in a table using sum formula , is it possible to achieve in power bi?

jmuthukumaran_0-1649170115875.png

 

1 ACCEPTED SOLUTION
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Solution uploaded to https://1drv.ms/x/s!Akd5y6ruJhvhuUOWen72PIQ9RqBY?e=y6yIoA 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Number.Type),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Index", {"Country"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Attribute] <> "Category" and [Attribute] <> "Index")),
    #"Grouped Rows" = Table.Group(#"Filtered Rows", {"Country", "Attribute"}, {{"Temp", each List.Sum([Value]), type number}}),
    #"Pivoted Column" = Table.Pivot(#"Grouped Rows", List.Distinct(#"Grouped Rows"[Attribute]), "Attribute", "Temp"),
    #"Added Custom" = Table.AddColumn(#"Pivoted Column", "Category", each "Cuts"),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Index", each List.Max(Table.SelectRows(#"Added Index", (x)=> x[Country]=[Country])[Index])+0.1),
    #"Appended Query" = Table.Combine({#"Added Index", #"Added Custom1"}),
    #"Sorted Rows" = Table.Sort(#"Appended Query",{{"Index", Order.Ascending}}),
    #"Removed Columns" = Table.RemoveColumns(#"Sorted Rows",{"Index"})
in
    #"Removed Columns"

 

View solution in original post

3 REPLIES 3
Vijay_A_Verma
Most Valuable Professional
Most Valuable Professional

Solution uploaded to https://1drv.ms/x/s!Akd5y6ruJhvhuUOWen72PIQ9RqBY?e=y6yIoA 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, 1, Number.Type),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Added Index", {"Country"}, "Attribute", "Value"),
    #"Filtered Rows" = Table.SelectRows(#"Unpivoted Other Columns", each ([Attribute] <> "Category" and [Attribute] <> "Index")),
    #"Grouped Rows" = Table.Group(#"Filtered Rows", {"Country", "Attribute"}, {{"Temp", each List.Sum([Value]), type number}}),
    #"Pivoted Column" = Table.Pivot(#"Grouped Rows", List.Distinct(#"Grouped Rows"[Attribute]), "Attribute", "Temp"),
    #"Added Custom" = Table.AddColumn(#"Pivoted Column", "Category", each "Cuts"),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Index", each List.Max(Table.SelectRows(#"Added Index", (x)=> x[Country]=[Country])[Index])+0.1),
    #"Appended Query" = Table.Combine({#"Added Index", #"Added Custom1"}),
    #"Sorted Rows" = Table.Sort(#"Appended Query",{{"Index", Order.Ascending}}),
    #"Removed Columns" = Table.RemoveColumns(#"Sorted Rows",{"Index"})
in
    #"Removed Columns"

 

jmuthukumaran
Frequent Visitor

Thanks for the response, 

My Source is an excel file where it contains country , category(order, ship only), Months (Jan , Feb , so on ) as columns , i need to create a tabular report like for each country data  need to add a new row at the end called "cuts" with formula (sum of order - sum of ship) for that country. hope this helps

serpiva64
Solution Sage
Solution Sage

Hi,

it's not clear to me what you need, can you explain again and make an exemple?

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors
Top Kudoed Authors