Forum Discussion
jmuthukumaran
4 years agoFrequent 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?
- 4 years ago
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"
Vijay_A_Verma
4 years agoMost 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"