ElseIf / CASE ELSE

Hello everyone,
EazyBI is very powerful tool and I am quite new user. Therefore, I would like to ask you for benevolence.

I would like to check if there is any options to use ElseIf (or equivalent) in formulas? I have tried to use ELSE CASE or CASE ELSE and none worked. So far I had to create cascading CASE WHEN statements, but it is usually not best practice.

Here is example:

CASE WHEN [Client].Currentmember.Name = "Client A"
    THEN 1
  ELSE 
    CASE WHEN [Client].Currentmember.Name = "Client B" 
      THEN 2
    ELSE 
      CASE WHEN [Client].Currentmember.Name = "Client C"
        THEN 3 
    END 
  END
END

Hi,

You may want to try Case when in little bit different way here:

CASE [Client].Currentmember.Name
WHEN "Client A" THEN 1
WHEN "Client B" THEN 2
WHEN "Client C" THEN 3
END

Martins / eazyBI support

1 Like

This is much better, thank you. Is there any option if subsquent conditions should contain different variables or comparing methods. Is it possible to optimize following code?

CASE WHEN [Client].Currentmember.Name = "Client A"
    THEN 1
  ELSE 
    CASE WHEN [Author].Currentmember.Name = "Author A" 
      THEN 2
    ELSE 
      CASE WHEN [Client].Currentmember.Name <> "Client C"
        THEN 3 
    END 
  END
END

Hi,

In such case, you should use the approach you already found.

Martins / eazyBI support

What if I want that search with wildcard?, for example:

WHEN “Client South.*” THEN 10

What’s the syntax on that case? Thanks!

Hi,

Try this code in your case:

CASE 
WHEN [Client].Currentmember.Name matches "Client South.*"
THEN 10
END

.* at the end of the string would search any symbol in the following string characthers

Martins / eazyBI support

1 Like