• 0

# CASE statement returns a blank value no matter what

## Question

I have a datapage which make about 14 different calculations to get to a list of calculated fields. I am trying to take any row in which there is a "2" and display "Primary" in this row. Each of the calc fields contains the value of blank (perhaps NULL? it is a query that is returning no results), 0, 1 or 2. Below is my case statement that is not playing nice. I appreciate any input.

```CASE
WHEN [@calcfield:3] = 2 THEN 'PRIMARY'
WHEN [@calcfield:4] = 2 THEN 'PRIMARY'
WHEN [@calcfield:5] = 2 THEN 'PRIMARY'
WHEN [@calcfield:6] = 2 THEN 'PRIMARY'
WHEN [@calcfield:7] = 2 THEN 'PRIMARY'
WHEN [@calcfield:8] = 2 THEN 'PRIMARY'
WHEN [@calcfield:9] = 2 THEN 'PRIMARY'
WHEN [@calcfield:10] = 2 THEN 'PRIMARY'
WHEN [@calcfield:11] = 2 THEN 'PRIMARY'
WHEN [@calcfield:12] = 2 THEN 'PRIMARY'
WHEN [@calcfield:13] = 2 THEN 'PRIMARY'
WHEN [@calcfield:14] = 2 THEN 'PRIMARY'
WHEN [@calcfield:15] = 2 THEN 'PRIMARY'
WHEN [@calcfield:16] = 2 THEN 'PRIMARY'
WHEN [@calcfield:17] = 2 THEN 'PRIMARY'
ELSE 'NOT'
END```

## Recommended Posts

• 0

Hi @NickO,

I think you need to simply combine the condition for assigning 'Primary' value with OR logic operator.

Perhaps you should try the following expression:

```CASE
WHEN

[@calcfield:3] = 2 OR
[@calcfield:4] = 2 OR
[@calcfield:5] = 2 OR
[@calcfield:6] = 2 OR
[@calcfield:7] = 2 OR
[@calcfield:8] = 2 OR
[@calcfield:9] = 2 OR
[@calcfield:10] = 2 OR
[@calcfield:11] = 2 OR
[@calcfield:12] = 2 OR
[@calcfield:13] = 2 OR
[@calcfield:14] = 2 OR
[@calcfield:15] = 2 OR
[@calcfield:16] = 2 OR
[@calcfield:17] = 2 THEN 'PRIMARY'

ELSE 'NOT'
END```

Hope this helps.

Regards,

vitalikssssss

##### Share on other sites

• 0

Thanks @Vitalikssssss, brain freeze on my part. I ended up doing it differently for my solution, but your suggestion was correct for that approach.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.