Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers!
Enter the sweepstakes now!Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.
Hello,
I am trying to create a custom column from 2 other columns to list column names if the values match "Y". So I have 2 columns namely A1 and A2 and if any of the rows have Y as value then I want that column name to be in this custom column and if both A1 and A2 have "Y" on the same row then I want A1,A2 in that row and of both have "N" then it should be empty as shown below
A1 | A2 | Custom Column |
N | N | |
Y | N | A1 |
N | Y | A2 |
Y | Y | A1,A2 |
I tried using below IF conditions but it gave me an error"Cannot convert value 'A3' of type Text to type True/False.
Solved! Go to Solution.
CalculatedColumn,
=SWITCH(TRUE(),
MAINT_ACTIVITY_TABLE[A1]="N" && MAINT_ACTIVITY_TABLE[A1]="N", BLANK(),
MAINT_ACTIVITY_TABLE[A1]="Y" && MAINT_ACTIVITY_TABLE[A1]="N","A1",
MAINT_ACTIVITY_TABLE[A1]="N" && MAINT_ACTIVITY_TABLE[A1]="Y","A2",
MAINT_ACTIVITY_TABLE[A1]="Y" && MAINT_ACTIVITY_TABLE[A1]="Y","A1,A2",
BLANK()
)
Proud to be a Super User! | |
DAX doesn’t support iterating over columns in a row context directly. I recommend unpivoting the table and the create a calculate column.
Proud to be a Super User! | |
Ok I will keep digging and in the meantime your initial solution worked for my original post so accepting that as the solution for the sample data
CalculatedColumn,
=SWITCH(TRUE(),
MAINT_ACTIVITY_TABLE[A1]="N" && MAINT_ACTIVITY_TABLE[A1]="N", BLANK(),
MAINT_ACTIVITY_TABLE[A1]="Y" && MAINT_ACTIVITY_TABLE[A1]="N","A1",
MAINT_ACTIVITY_TABLE[A1]="N" && MAINT_ACTIVITY_TABLE[A1]="Y","A2",
MAINT_ACTIVITY_TABLE[A1]="Y" && MAINT_ACTIVITY_TABLE[A1]="Y","A1,A2",
BLANK()
)
Proud to be a Super User! | |
Thanks it worked on the sample table I have with 2 columns and I got the result but in realtime my report has 12 different columns and the custom column I need should lookup all the 12 columns and get the data. So do I need to work all the combinations for 12 columns to get the expected output or is there another simplified way to achieve this?
The real report columns below:
Please help
Check out the May 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
72 | |
71 | |
70 | |
51 | |
47 |
User | Count |
---|---|
45 | |
38 | |
29 | |
29 | |
28 |