Skip to main content

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
QlikWorld 2023, a live, in-person thrill ride. Save $300 before February 6: REGISTER NOW!
cancel
Showing results for 
Search instead for 
Did you mean: 
MrBosch
Contributor III
Contributor III

What is the syntax to evaluate a variable and show a text depending the value in Qlik View

Hello, the infinite pool of mighty wisdom,

Can anyone give me some tips on how I can make the following happen:

I am building a report. In the report, a variable needs to be evaluated and the corresponding textual content should be inserted.

An easy example: is the variable WEIGHT.

I create a New Text Object and need the variable to be evaluated as follows:

If WEIGHT is
< 50 texts should appear: 'You need to gain weight. You can achieve this ...'
50 - 75 'Great weight. Keep a healthy lifestyle.'
>75 'You should lose some weight. You could consider ...'.

Thanks for your help! Highly appreciated.

Labels (1)
3 Solutions

Accepted Solutions
marcus_sommer
MVP & Luminary
MVP & Luminary

Maybe something like: if(WEIGHT < 50, 'a', if(WEIGHT > 75, 'c', 'b'))

- Marcus

View solution in original post

marcus_sommer
MVP & Luminary
MVP & Luminary

In general quite similar - and if the order - ascend or descend - of the check is continuously you don't need to check for between. This means the following should be working:

if(WEIGHT < 25, 'a', if(WEIGHT < 30, 'b', if(WEIGHT < 35, 'c', 'd')))

- Marcus

View solution in original post

MrBosch
Contributor III
Contributor III
Author

Thanks Marcus, the order might have been a problem. 

Perhaps for others: this is the solution I have implemented:

=If ([BMI] < 18.5, 'Text for BMI less than 18.5'
,If ([BMI] >= 18.5 and [BMI] <25, 'Text for BMI between 18.5 and 25'
,If ([BMI] >= 25 and [BMI] <30, 'Text for BMI between 25 and 30'
,If ([BMI] >= 30 and [BMI] <90, 'Text for BMI BMI above 30'
,''
))))

So I leave the ELSE (row 5 in the code above) out and define all possible conditions. If you don't select a single occurence it will then not show the ELSE text (which I did see initially when the whole population had an average BMI of 25.7).

Also: don't use a ' in the Text area... (Yup made that mistake too and couldn't initially figure out why the expression gave an error. You can solve this by the escape sequence double quote: ''

Hope this helps someone someday.

View solution in original post

4 Replies
marcus_sommer
MVP & Luminary
MVP & Luminary

Maybe something like: if(WEIGHT < 50, 'a', if(WEIGHT > 75, 'c', 'b'))

- Marcus

MrBosch
Contributor III
Contributor III
Author

Thanks Marcus. Great solution. Perhaps one more addition: now the test is <50 A, >75 B and else (between 50-75) C.

What would be the syntax if someone wants to add more conditions? So... to get 'D'?

So: 
WEIGHT <25 'A'
WEIGHT 25-30 'B'
WEIGHT 30-35 'C'
WEIGHT >35 'D'

marcus_sommer
MVP & Luminary
MVP & Luminary

In general quite similar - and if the order - ascend or descend - of the check is continuously you don't need to check for between. This means the following should be working:

if(WEIGHT < 25, 'a', if(WEIGHT < 30, 'b', if(WEIGHT < 35, 'c', 'd')))

- Marcus

MrBosch
Contributor III
Contributor III
Author

Thanks Marcus, the order might have been a problem. 

Perhaps for others: this is the solution I have implemented:

=If ([BMI] < 18.5, 'Text for BMI less than 18.5'
,If ([BMI] >= 18.5 and [BMI] <25, 'Text for BMI between 18.5 and 25'
,If ([BMI] >= 25 and [BMI] <30, 'Text for BMI between 25 and 30'
,If ([BMI] >= 30 and [BMI] <90, 'Text for BMI BMI above 30'
,''
))))

So I leave the ELSE (row 5 in the code above) out and define all possible conditions. If you don't select a single occurence it will then not show the ELSE text (which I did see initially when the whole population had an average BMI of 25.7).

Also: don't use a ' in the Text area... (Yup made that mistake too and couldn't initially figure out why the expression gave an error. You can solve this by the escape sequence double quote: ''

Hope this helps someone someday.