Unstack, Flatten or Compress data into a single row per employee

Bill_Kro

New Member
Joined
Oct 28, 2017
Messages
14
I have a download from by HR system but I'm having problems getting the data into a format for the report I have to generate.

I want a report that looks like the following...
Employee Name
Medical
Dental
Vision
Vision Pay
Flex
Emp1
MedBasicFamily
DenBasicFam
Vision
$18.00
Flex
Emp2
MedBasicSingle
Vision
$8.50

<tbody>
</tbody>






The data that I have looks like this...

<tbody></tbody>
Employee Name
Medical
Dental
Vision
Vision Pay
Flex
Emp1
DenBasicFam
Emp1
MedBasicFamily
Emp1
Vision
$18.00
Emp1
Flex
Emp2
MedBasicSingle
Emp2
Vision
$8.50
...

<tbody>
</tbody>





<colgroup><col width="209"><col width="198" span="3"><col width="90"><col width="198"></colgroup><tbody>
</tbody>

What is the easiest way to compress this data to one line per employee?
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
is that what you want?

done with PowerQuery (Get&Transform)

Employee NameMedicalDentalVisionVision PayFlexEmployee NameMedicalDentalVisionVision PayFlex
Emp1DenBasicFamEmp1MedBasicFamilyDenBasicFamVision$18.00Flex
Emp1MedBasicFamilyEmp2MedBasicSingleVision$8.50
Emp1Vision$18.00
Emp1Flex
Emp2MedBasicSingle
Emp2Vision$8.50
 
Upvote 0
here is a M-code for example above

Code:
[SIZE=1]let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Employee Name", type text}, {"Medical", type text}, {"Dental", type text}, {"Vision", type text}, {"Vision Pay", type text}, {"Flex", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Employee Name"}, {{"Count", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Medical", each List.Distinct(Table.Column([Count],"Medical"))),
    #"Extracted Values" = Table.TransformColumns(#"Added Custom", {"Medical", each Text.Combine(List.Transform(_, Text.From)), type text}),
    #"Added Custom1" = Table.AddColumn(#"Extracted Values", "Dental", each List.Distinct(Table.Column([Count],"Dental"))),
    #"Extracted Values1" = Table.TransformColumns(#"Added Custom1", {"Dental", each Text.Combine(List.Transform(_, Text.From)), type text}),
    #"Added Custom2" = Table.AddColumn(#"Extracted Values1", "Vision", each List.Distinct(Table.Column([Count],"Vision"))),
    #"Extracted Values2" = Table.TransformColumns(#"Added Custom2", {"Vision", each Text.Combine(List.Transform(_, Text.From)), type text}),
    #"Added Custom3" = Table.AddColumn(#"Extracted Values2", "Vision Pay", each List.Distinct(Table.Column([Count],"Vision Pay"))),
    #"Extracted Values3" = Table.TransformColumns(#"Added Custom3", {"Vision Pay", each Text.Combine(List.Transform(_, Text.From)), type text}),
    #"Added Custom4" = Table.AddColumn(#"Extracted Values3", "Flex", each List.Distinct(Table.Column([Count],"Flex"))),
    #"Extracted Values4" = Table.TransformColumns(#"Added Custom4", {"Flex", each Text.Combine(List.Transform(_, Text.From)), type text})
in
    #"Extracted Values4"[/SIZE]
 
Upvote 0

Forum statistics

Threads
1,215,061
Messages
6,122,921
Members
449,094
Latest member
teemeren

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