Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Showing results for

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!**

- Qlik Community
- :
- All Forums
- :
- QlikView App Dev
- :
- What is the syntax to evaluate a variable and show...

Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Showing results for

MrBosch

Contributor III

2022-06-10
04:00 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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.

185 Views

3 Solutions

Accepted Solutions

marcus_sommer

MVP & Luminary

2022-06-10
07:58 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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

- Marcus

165 Views

marcus_sommer

MVP & Luminary

2022-06-13
03:30 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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

143 Views

MrBosch

Contributor III

2022-06-14
03:59 AM

Author

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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.

131 Views

4 Replies

marcus_sommer

MVP & Luminary

2022-06-10
07:58 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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

- Marcus

166 Views

MrBosch

Contributor III

2022-06-10
09:58 AM

Author

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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'

160 Views

marcus_sommer

MVP & Luminary

2022-06-13
03:30 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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

144 Views

MrBosch

Contributor III

2022-06-14
03:59 AM

Author

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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.

132 Views