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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
OPS-MLTSD
Post Patron
Post Patron

remove duplicates in columns after unpivoting

Hello,

 

I have a survey result from excel that I imported into power query, the excel table is currently in a wide format, for the purposes of my visualizations and analysis, I was able to turn the wide table into a long table using unpivot. This is what the table used ot look like:

 

ResponseIDAre you familiar with the Cubic Program?How would you rate it's ease of useIf you chose unsure for easy of use, please explainHow would you rate how easily it can be acquired?If you chose unsure for ease of acquiring, please explainAre you familiar with the Boltic program?How would you rate it's ease of useIf you chose unsure for easy of use, please explainHow would you rate how easily it can be acquired?If you chose unsure for ease of acquiring, please explain
1YeslowN/amedN/aNoN/aN/aN/aN/a
2NoN/aN/aN/aN/aYeshighN/ahighN/a

 

after unpivoting, I have come across duplicate issues that looks like this, and I cannot solve the issue to get the numbers to be unique. this is how the duplicates are showing up:

Uniq IDResponseIDProgramProgram ResponseEase of UseEase of Use Response
Cubic 11Cubic YesHow would you rate it's ease of use?N/a
Cubic 11CubicYesHow would you rate it's ease of use?2low
Cubic 11CubicYesHow would you rate it's ease of use?3med
Cubic 11Cubic YesHow would you rate it's ease of use?4high
Boltic 11BolticNoHow would you rate it's ease of use?N/a

 

this is how I want the data to look like:

Uniq IDResponseIDProgramEase of UseEase of Use UnsureEasily AcquiredEasily Acquired Unsure
Cubic 11Cubic LowN/amedN/a
Boltic 11BolitcN/aN/aN/aN/a
Cubic 22Cubic N/aN/aN/aN/a
Boltic 22BolticHighN/ahighN/a

 

if someone could please help me with the duplicate issue, I would really appreicate it

3 REPLIES 3
wdx223_Daniel
Super User
Super User

wdx223_Daniel_0-1675825626503.png

load your data without headers

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("3Y/NTsNADIRfxco5EqUXjhW0B3qJKm4o5OAmTtbSZh32RyFvjxvoj6rSB+Ay8o4+e3bKMnujMIgLtN1kefbsCSZJ0GLPltHDyNFANATrtOcadl46j/1K0VcZYZRkm3nBYyTg+JEWi+VTAMJAIC2kQIpu25mpjaibXEia0oo/UNMvlcNg5yX6Giyyux1g1FKK7aRZUKODPQHWn4k9Nav7SfN/flh23Y28v7u/iI1afvi35au8zB71wjsFVSujavGAqj01p7mQ83ilhwPL+8jxuuHOnKyLR1V9Aw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t, Column4 = _t, Column5 = _t, Column6 = _t, Column7 = _t, Column8 = _t, Column9 = _t, Column10 = _t, Column11 = _t]),
    Custom1 = let a={"Cubic","Boltic"},b=Table.ToRows(Source) in #table({"Uniq ID","ResponseID","Program","Ease of Use","Ease of Use Unsure","Easily Acquired","Easily Acquired Unsure"},List.TransformMany(List.Skip(b),each List.Split(List.Skip(List.Zip({b{0},_})),5),(x,y)=>let c=List.Select(a,each Text.Contains(y{0}{0},_)){0}? in {c&" "&Text.From(x{0}),x{0},c}&List.Zip(List.Skip(y)){1}))
in
    Custom1

@wdx223_Daniel also, my data source in a excel sheet and I have many other columns in my excel sheet so I am not really understanding your formula above, if you could please help that would be much appreciated

@wdx223_Daniel 

 

I am not understanding your approach, could you explain the formula below? Appreciate your help!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors