cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
samurijv2 Regular Visitor
Regular Visitor

Return column name each time specific cell value is detected?

I have a dataset where the rows refer to different people and each colum referers to a different attribute. Each cell has a value of 0 or 1, with 1 indicating that the person has the attribute, and 0 denoting that they do not. 

 

sample data for power bi problem.PNG

 

I need help creating a measure that will look for the 1s in each row and return the column name for each 1 it finds. The expected output based on the data above would be something like:

 

Person 1: Attribute 2

Person 2: Attribute 5

Person 3: Attribute 1, Attribute 2, Attribute 4

Person 4: Attribute 2, Attribute 3

Person 5: Attribute 1, Attribute 4, Attribute 5

 

Thanks in advance for your help! 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support Team
Community Support Team

Re: Return column name each time specific cell value is detected?

Hi @samurijv2 ,

 

you can select the three columns Attribute 1- Attribute 5 in Query Editor, then unpivot these column to row data like picture below, click "Close & Apply".

 

8.png9.png

 

 

 

 

 

 

 

 

 

 

Then create new column1.

 

Column1= IF(Table1[Value]=1, Table1[Attribute],BLANK())

 

Finally, you can create calculated table using DAX below.

 

NewTable = ADDCOLUMNS(SUMMARIZE(Table1,Table1[Person]),"Expected", CALCULATE(CONCATENATEX(Table1, Table1[Column1], " ")))

 

10.png

 

 

 

 

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

2 REPLIES 2
Highlighted
Community Support Team
Community Support Team

Re: Return column name each time specific cell value is detected?

Hi @samurijv2 ,

 

you can select the three columns Attribute 1- Attribute 5 in Query Editor, then unpivot these column to row data like picture below, click "Close & Apply".

 

8.png9.png

 

 

 

 

 

 

 

 

 

 

Then create new column1.

 

Column1= IF(Table1[Value]=1, Table1[Attribute],BLANK())

 

Finally, you can create calculated table using DAX below.

 

NewTable = ADDCOLUMNS(SUMMARIZE(Table1,Table1[Person]),"Expected", CALCULATE(CONCATENATEX(Table1, Table1[Column1], " ")))

 

10.png

 

 

 

 

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

samurijv2 Regular Visitor
Regular Visitor

Re: Return column name each time specific cell value is detected?

This worked perfectly! Thanks for your assistance. 

Helpful resources

Announcements
Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Power BI Helps Homeless and Trouble Youth

Power BI Helps Homeless and Trouble Youth

We spoke with Power BI Super User, Greg Deckler, about his charity work

MBAS Gallery

Watch Sessions On Demand!

Continue your learning in our online communities.

Users Online
Currently online: 111 members 1,678 guests
Please welcome our newest community members: