Forum Discussion

ngct1112's avatar
ngct1112
Post Patron
4 years ago
Solved

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...
  • VahidDM's avatar
    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!!