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!!
VahidDM
4 years agoSuper User
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!!