Bomino
Member
Hello,
I have a data set that I grouped and now I would like to calculate the percentage that each Product makes up of the Grand Total in Sales and Transactions. My code ( shown below) is not giving me the desired output.
Here is the desired output
Any help will be greatly appreciated.
Thank you.
I have a data set that I grouped and now I would like to calculate the percentage that each Product makes up of the Grand Total in Sales and Transactions. My code ( shown below) is not giving me the desired output.
Code:
let
Source = MyData,
#"Grouped Rows" = Table.Group(Source, {"Product"}, {{"Sales", each List.Sum([NetValue]), type number}, {"Transactions", each Table.RowCount(_), type number},{"SupplierCount",each List.Count(List.Distinct([SupplierName])),Int64.Type}}),
Sales = Table.Column(#"Grouped Rows","Sales"),
TotalSales = List.Sum(Sales),
Trx =Table.column(#"Grouped Rows","Transactions"),
TotalTrx = List.Sum(Trx),
Result=Table.AddColumn(#"Grouped Rows",{{"% Sales",each[Sales]/TotalSales,type number},{"% Transactions",each[Tansactions]/TotalTrx,type number}})
in
Result
Here is the desired output
Any help will be greatly appreciated.
Thank you.