Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
QlikWorld, June 24-25, 2020. Free virtual event for DI and DA gurus. Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
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.

Tags (1)
8 Replies
Highlighted

Re: Calculated measure with several conditions

The nested if isn't working?

If(Condition1Met, Something1,

If(Condition2Met, Something2,

If(Condition3Met, Something3.....

Highlighted
Specialist III
Specialist III

Re: Calculated measure with several conditions

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:

Screenshot_2.png

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.

Highlighted
Not applicable

Re: Calculated measure with several conditions

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

Highlighted
Not applicable

Re: Calculated measure with several conditions

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

Highlighted
Specialist III
Specialist III

Re: Calculated measure with several conditions

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.

Highlighted

Re: Calculated measure with several conditions

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

Highlighted
Not applicable

Re: Calculated measure with several conditions

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

Example 2 Sense.png

Highlighted
Creator II
Creator II

Re: Calculated measure with several conditions

Hi Thiago,

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

LD