Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
STIBBS_807
Resolver I
Resolver I

Appending Column of Duplicate Data into One Row

Need more assistance from the community. 

 

I have a excel spreadsheet with Monitor data in it.  It looks like this:

STIBBS_807_0-1621281880803.png

I would like to transform the data into this:

STIBBS_807_1-1621281938846.png

Here is my code so far:

let
Source = Csv.Document(File.Contents(" ....\Testing\Displays.csv"),[Delimiter=",", Columns=5, Encoding=1252, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Sorted Rows" = Table.Sort(#"Promoted Headers",{{"Computer", Order.Ascending}}),
#"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 0, 1, Int64.Type),
#"Removed Columns" = Table.RemoveColumns(#"Added Index",{"Manufacturer", "Model", "Description"})
in
#"Removed Columns"

 

I have tried other Merge Rows into One Row solutions from this community but with no success.  Wonder if someone would assist me in flattening out my data.

 

Thank you in advance.😊

 

2 ACCEPTED SOLUTIONS
HotChilli
Super User
Super User

We always prefer a data sample rather than a picture.

Anyway, the strategy is to add an Index (per Computer category) then perform a pivot on this new Index column to create the new column headings.

Step1 Group by Computer with new column "all" (choose 'All Rows')

Step 2 Add New Column with code like:

Table.AddIndexColumn([all], "Count", 1, 1)

Step 3 Expand the New Column (return everything and we'll tidy up columns after)

Step 4 Remove redundant columns.

Step 5 Select "Count" column and Pivot (from the Transform menu). Choose the Values column and 'Don't aggregate'

That should be it.

-------------------------

Let me know how it goes as that's some reasonably advanced operations. 

View solution in original post

Here is a sample of my data

ComputerManufacturerModelDescriptionSerial Number

8WOODSDRIVEACRACER V243HGeneric PnP MonitorLHG080334231
8WOODSDRIVEACRACER X233HGeneric PnP MonitorLG1080204220
FFD001ACRV277UGeneric PnP MonitorTDCAA002852A
FFD001GSM24MB35Generic PnP Monitor610NTMX00419
FFD001GSM24MB35Generic PnP Monitor610NTTQ00417
FFD601(Standard monitor types) Generic Non-PnP Monitor 
FFD602ACRAcer S231HLGeneric PnP MonitorLNZ080024214
FFD603ACRAcer S231HLGeneric PnP MonitorLNZ080024214
FFD604ACRAcer S231HLGeneric PnP MonitorLNZ080024214
FFD605(Standard monitor types) Generic Non-PnP Monitor 
FFD606ACRAcer H236HLGeneric PnP MonitorLX1AA0034210
FFD607ACRAcer S231HLGeneric PnP MonitorLNZ080024214
FFD608GSM24MB35Generic PnP Monitor609NTABCX552
FFD608GSM24MB35Generic PnP Monitor610NTSU00414
FFD609ACRAcer S231HLGeneric PnP MonitorLNZ080024214
FFD610ACRAcer S231HLGeneric PnP MonitorLNZ080024214
FFD612(Standard monitor types) Generic Non-PnP Monitor 
FFD613ACRAcer B236HLGeneric PnP MonitorLYXAA0014200
FFD613ACRV233HGeneric PnP MonitorLGT0C0444060
FFD614ACRACER V243HGeneric PnP MonitorLHG080334231
FFD614ACRV233HGeneric PnP MonitorLGT0C0444060
FFD615ACRACER X233HGeneric PnP MonitorLG1080204220
FFD616ACRS240HLGeneric PnP MonitorLU50D0128532

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the Excel file and in another tab of the file, show the expected result clearly.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
HotChilli
Super User
Super User

We always prefer a data sample rather than a picture.

Anyway, the strategy is to add an Index (per Computer category) then perform a pivot on this new Index column to create the new column headings.

Step1 Group by Computer with new column "all" (choose 'All Rows')

Step 2 Add New Column with code like:

Table.AddIndexColumn([all], "Count", 1, 1)

Step 3 Expand the New Column (return everything and we'll tidy up columns after)

Step 4 Remove redundant columns.

Step 5 Select "Count" column and Pivot (from the Transform menu). Choose the Values column and 'Don't aggregate'

That should be it.

-------------------------

Let me know how it goes as that's some reasonably advanced operations. 

Here is a sample of my data

ComputerManufacturerModelDescriptionSerial Number

8WOODSDRIVEACRACER V243HGeneric PnP MonitorLHG080334231
8WOODSDRIVEACRACER X233HGeneric PnP MonitorLG1080204220
FFD001ACRV277UGeneric PnP MonitorTDCAA002852A
FFD001GSM24MB35Generic PnP Monitor610NTMX00419
FFD001GSM24MB35Generic PnP Monitor610NTTQ00417
FFD601(Standard monitor types) Generic Non-PnP Monitor 
FFD602ACRAcer S231HLGeneric PnP MonitorLNZ080024214
FFD603ACRAcer S231HLGeneric PnP MonitorLNZ080024214
FFD604ACRAcer S231HLGeneric PnP MonitorLNZ080024214
FFD605(Standard monitor types) Generic Non-PnP Monitor 
FFD606ACRAcer H236HLGeneric PnP MonitorLX1AA0034210
FFD607ACRAcer S231HLGeneric PnP MonitorLNZ080024214
FFD608GSM24MB35Generic PnP Monitor609NTABCX552
FFD608GSM24MB35Generic PnP Monitor610NTSU00414
FFD609ACRAcer S231HLGeneric PnP MonitorLNZ080024214
FFD610ACRAcer S231HLGeneric PnP MonitorLNZ080024214
FFD612(Standard monitor types) Generic Non-PnP Monitor 
FFD613ACRAcer B236HLGeneric PnP MonitorLYXAA0014200
FFD613ACRV233HGeneric PnP MonitorLGT0C0444060
FFD614ACRACER V243HGeneric PnP MonitorLHG080334231
FFD614ACRV233HGeneric PnP MonitorLGT0C0444060
FFD615ACRACER X233HGeneric PnP MonitorLG1080204220
FFD616ACRS240HLGeneric PnP MonitorLU50D0128532

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors