Power Query - Return column name each time specific cell value is detected?

M, Johannes 86 Reputation points
2020-10-29T15:15:15.23+00:00

Hey guys!
I got this Table in the Power Query Editor. There are several Persons with different Attributes.
36142-3.png
How can I get my table in a format like this in the Power Query Editor? The first row schould be the person and the second is filled with the attributes were the value is one. They should be in a single row with a seperating figure.
36064-4.png
If you could help me that would be awesome and would safe my day!

Microsoft 365 and Office | Excel | For business | Windows
Community Center | Not monitored
{count} votes

Answer accepted by question author
  1. Lz._ 38,106 Reputation points Volunteer Moderator
    2020-10-29T16:18:49.44+00:00

    Hi

        PreviousStepName = ...
        UnpivotedOtherColumns = Table.UnpivotOtherColumns(PreviousStepName, {"Person"}, "Attribute", "Value"),
        FilteredValues = Table.SelectRows(UnpivotedOtherColumns, each ([Value] = 1)),
        GroupedRows = Table.Group(FilteredValues, {"Person"},
            {{"Attributes", each Text.Combine([Attribute],", "), type text}}
        )
    
    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Ashish Mathur 100.8K Reputation points Volunteer Moderator
    2025-07-20T00:19:49.72+00:00

    Hi,

    This M code in Power Query works

    let
        Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
        #"Added Custom" = Table.AddColumn(Source, "Attributes", each Text.Combine(Table.SelectRows(Record.ToTable(_), each [Value]=1)[Name],", "))[[Person],[Attributes]]
    in
        #"Added Custom"
    

    Hope this helps.

    User's image

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.