Forum Discussion

Adam1V's avatar
Adam1V
Frequent Visitor
6 years ago
Solved

Custom Column - Multiple If Statement

Hi, Im extremly new to Power Bi so hoping this isnt a silly question.   Im looking to expand on employees initials within power bi and im trying to use a custom column to do so with the below form...
  • Adam1V's avatar
    6 years ago

    Actually just managed to resolve this, below for anyone else searching for this in the future;

     

    if [DESIGN ENGINEER] = "PG" then "PAUL Gxxxxx" else if [DESIGN ENGINEER] = "AB" then "ASHLEY Bxxxxx" else if [DESIGN ENGINEER] = "SG" then "SAM Gxxxxx" else if [DESIGN ENGINEER] = "TB" then "TOM Bxxxx" else if [DESIGN ENGINEER] = "NBJ" then "NATHAN Bxxxx" else if [DESIGN ENGINEER] = "LB" then "LLOYD Bxxxx" else if [DESIGN ENGINEER] = "DW" then "DAVE Wxxxx" else if [DESIGN ENGINEER] = "AMV" then "ADAM Vxxxx" else if [DESIGN ENGINEER] = "DB" then "DAVID Bxxxx" else ""
  • Anonymous's avatar
    Anonymous
    6 years ago

    Is this in the query editor? It looks like DAX syntax but that error sounds like the query editor, which uses a different language. If statements there have a completely different syntax.  In the query editor an if statement looks like this (case sensitive)

    if [DESIGN ENGINEER]="PG" then "PAUL Gxxxx"
    	else if [DESIGN ENGINEER]="AB" then "ASHLEY Bxxxx"
    	else if [DESIGN ENGINEER]="SG" then "SAM Gxxxx"
    	...
    	else ""