How to divide or direct percentage from sum column to each column value

srehman

Board Regular
Joined
Jan 4, 2020
Messages
210
Office Version
  1. 2016
Platform
  1. Windows
Hi Team,

I want to get divide or direct percentage of column A,B,C,D , Dead column by sum. no decimal required with percenatge. only in PQ.

I am doing one by one each column which long process.

Book1
CDEFGHIJ
2IndexSKUABCDDEADSUM
3115163160600006
4262958900600006
5369591300600006
6415131420600006
7526431470600006
8616021240600006
9726439080600006
10816298490600006
11913241130600006
121015120560600006
131164145520600006
141262957530600006
151362953570510006
161413482750510006
171528630060510006
181669595350420006
Sheet1
 

Attachments

  • Desired Result.PNG
    Desired Result.PNG
    32.9 KB · Views: 16
  • Data1.PNG
    Data1.PNG
    27.9 KB · Views: 16

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Here is the Mcode for only adjusting Column A. You will need to do the same for each of the other columns. I saw no point in repeating this exercise since it was for a learning experience exercise and not the actual data.

Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Index", Int64.Type}, {"SKU", Int64.Type}, {"A", Int64.Type}, {"B", Int64.Type}, {"C", Int64.Type}, {"D", Int64.Type}, {"DEAD", Int64.Type}, {"SUM", Int64.Type}}),
    #"Inserted Percent Of" = Table.AddColumn(#"Changed Type", "Percent Of", each [A] / [SUM] * 100, type number),
    #"Inserted Round Up" = Table.AddColumn(#"Inserted Percent Of", "Round Up", each Number.RoundUp([Percent Of]), Int64.Type),
    #"Removed Columns" = Table.RemoveColumns(#"Inserted Round Up",{"Percent Of"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",{"Index", "SKU", "Round Up", "A", "B", "C", "D", "DEAD", "SUM"}),
    #"Removed Columns1" = Table.RemoveColumns(#"Reordered Columns",{"A"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns1",{{"Round Up", "A"}})
in
    #"Renamed Columns"
 
Upvote 0
Thanks Yes i have done same way one by one.
I was looking for short method. I understand sometime no choice.

Thanks for your time. You always helpful.
 
Upvote 0
Don't know if there is a way to do multiple columns at once. But once the code is done, it can be used over and over again.
 
Upvote 0
try
Rich (BB code):
// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Unpivot = Table.UnpivotOtherColumns(Source, {"Index", "SKU", "SUM"}, "Attribute", "Value"),
    Prefix = Table.TransformColumns(Unpivot, {{"Attribute", each "% " & _, type text}}),
    PercentOf = Table.AddColumn(Prefix, "Percent Of", each [Value] / [SUM] * 100, type number),
    Round = Table.TransformColumns(PercentOf,{{"Percent Of", each Number.Round(_, 0), type number}}),
    RC = Table.RemoveColumns(Round,{"Value"}),
    Pivot = Table.Pivot(RC, List.Distinct(RC[Attribute]), "Attribute", "Percent Of", List.Sum),
    TSC = Table.SelectColumns(Pivot,{"Index", "SKU", "% A", "% B", "% C", "% D", "% DEAD", "SUM"})
in
    TSC
 
Upvote 0
Oh i Just checked i will give you response time difference it was night here in Melbourne.
Thank again Sandy
 
Upvote 0
Hi Sandy,

I have implemented your approached unbelievable ideas you have.

Thanks a lot.
 

Attachments

  • % Results.PNG
    % Results.PNG
    33.6 KB · Views: 12
Upvote 0

Forum statistics

Threads
1,223,789
Messages
6,174,579
Members
452,573
Latest member
Cpiet

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top