Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for
Did you mean:
Not applicable

## Calculated measure with several conditions

I need to create a calculated measure with several conditions. Theoretically need to implement as an expression:

if (condition) then

else if (condition) then

else

I could only implement the If and Else.

8 Replies
MVP

The nested if isn't working?

If(Condition1Met, Something1,

If(Condition2Met, Something2,

If(Condition3Met, Something3.....

Partner - Specialist III

Give us more details.

As Sunny said use Nested Ifs.

For example:

```LOAD *,
if(value < 2, 'Number is less than 2',
If(value <= 3, 'Number is less or equal to 3', 'Number is more than 3')) as Result
INLINE [
value
1
2
3
4
];
```

The outcome would be this:

Practically you can you as many nested ifs as you wish. But according to the situation you can apply other methods to reach the result.

Not applicable
Author

but I needed to do the calculation of expressions because they need to calculate only a few lines of the PivotTable.

Not applicable
Author

I can use within expressions? And how I use Else?

Partner - Specialist III

If statement can be used in the script and in the expression. In both cases the logic is the same.

If works like following:

IF(logical condition, if logical condition is TRUE then do something, if logical condition is FALSE then do something)

Please test and create few examples yourself and you could easily handle the issue. Or just attach the sample qvw file.

MVP

I think if you can provide a sample with your expected output, we might be able to offer you better help rather than some guesswork

Not applicable
Author

Because the goal is a few lines is the sum of a few lines below as in the image:

Creator III

Hi Thiago,

Have you ever been able to get the answer for your question?

LD