How to unpivot many different section columns

alipezu

Board Regular
Joined
Oct 18, 2016
Messages
51
Hi All,
Though I have a previous thread similar to the current one. the only difference is each school has more 3 columns added to each school KG, Cycle1, Cycle2 and Cycle3 with Bus Assistant Name,ID and Mobile number.
Code:
[COLOR=#333333]let[/COLOR]    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(Source, {"Driver Name", "Driver ID", "Bus Number", "Bus Capacity"}, "Attribute", "Value"),
    #"Added Conditional Column" = Table.AddColumn(#"Unpivoted Columns", "Custom", each if Text.Contains([Attribute], "Students") then [Value] else null ),
    #"Added Conditional Column1" = Table.AddColumn(#"Added Conditional Column", "Custom.1", each if [Custom] = null then [Value] else null ),
    #"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column1",{"Value"}),
    #"Filled Down" = Table.FillDown(#"Removed Columns",{"Custom.1"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([Custom] <> null)),
    #"Replaced Value" = Table.ReplaceValue(#"Filtered Rows"," Students","",Replacer.ReplaceText,{"Attribute"}),
    #"Renamed Columns" = Table.RenameColumns(#"Replaced Value",{{"Attribute", "School Type"}, {"Custom.1", "School Name"}}),
    #"Reordered Columns" = Table.ReorderColumns(#"Renamed Columns",{"Driver Name", "Driver ID", "Bus Number", "Bus Capacity", "School Type", "School Name", "Custom"}),
    Finish = Table.RenameColumns(#"Reordered Columns",{{"Custom", "Total Students"}})
in [COLOR=#333333]    Finish[/COLOR]


The code above from a respected member works fine but what should I do with the added 3 columns to each school.
Please help me solve this.
here is the same workbook with 3 more columns added to each school: https://drive.google.com/file/d/0B9uKuwzDH_rQWW9GMXNKZVNuMkk/view?usp=sharing
 
Last edited:

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Thank you Bill but the Assistant Names,IDs and their Mobile numbers are missing. I changed the columns colours for each section which will give you more clearer view.
https://drive.google.com/file/d/0B9uKuwzDH_rQRkZLZ2hlWWMxZlk/view?usp=sharing
My second question is: What is the 'fxunpivot' and for what purpose you created that??
Apology If I sound stupid.. :) As I am a beginner to PQ.
Regards.
 
Last edited:
Upvote 0
Bill or anyone please solve as this is very important for me. I am sure its easy for you guys.
Thanks.
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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