Forum Discussion
ngct1112
4 years agoPost Patron
Union columns with changing values
Hi all, I am looking for a solution(with DAX) to union a few columns in the same table(A,B,C), meanwhile, changing the values to the column name if it is "fail". Orginal: Item A B C...
- 4 years ago
Hi ngct1112
Try this code to add a new table:
Table 2 = union( SELECTCOLUMNS('Table',"Item",[Item],"Appended",if([A]="Fail","A",[A])), SELECTCOLUMNS('Table',"Item",[Item],"Appended",if([B]="Fail","B",[B])), SELECTCOLUMNS('Table',"Item",[Item],"Appended",if([C]="Fail","C",[C])) )Output:
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Jihwan_Kim
4 years agoSuper User
Hi,
I am not sure if I understood your question correctly, but please check the below picture.
It is for the table creation.
New Table =
UNION (
SUMMARIZECOLUMNS (
Data[Item],
"Appended", IF ( MAX ( Data[A] ) = "Pass", "null", "A" )
),
SUMMARIZECOLUMNS (
Data[Item],
"Appended", IF ( MAX ( Data[B] ) = "Pass", "null", "B" )
),
SUMMARIZECOLUMNS (
Data[Item],
"Appended", IF ( MAX ( Data[C] ) = "Pass", "null", "C" )
)
)