Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
sspawar88
Creator II
Creator II

How use 'If condition' in Script of Qlikview?

I tried many times but it fails.

i have temperature data in which have a group of temperatures.

above -10
-10.1 to -13.9
-14 to -17.9
-18 & below

i want group of this temp as

above -10  as 'A'

-10.1 to -13.9 as'B'

-14 to -17.9 as 'C'

-18 & below as 'D' in one field(BANDS) on UI.


such groups are different for different regions and branch_types but i have to put all in this A,B,C, D.


for example where Temperature locate in my database e.g -->sum({$<param_name={'Temperature'} ,region_name=>}param_value).


when i click on row of 'Temperature' in 'param_name' it will show the values in 'param_value' field.



How i have to put the condition in Script so that on UI when i click on A row of BANDS field, it will give me visualization for certain group


i have attached QVW.

5 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try adding this to the load statement for that table:

     if(param_name = 'Temperature',

      if(param_value <= -18, 'D',

       if(param_value >= -17.9 and param_value <= 14 , 'C',

           if(param_value >= -13.9 and param_value <= 10.1 , 'B',

            if(param_value > -10, 'A'))))) AS BANDS

Note that your specification of the bands contains gaps. A value like -13.95 would not get a bands value.


talk is cheap, supply exceeds demand
Not applicable

Does the Case statement not work in Qlikview?

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Not in a load statement. If you use it in an sql statement then it depends on the database that's going to execute it.


talk is cheap, supply exceeds demand
Anonymous
Not applicable

if(temp< -18

      ,'D'

      ,if(temp< -14

      ,'C'

      ,if(temp< -10.1

      ,'B'

      ,'A'

      )

      )

      ) as [Temperature Bands]

Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

I have no idea what you're trying to calculate. But creating a BANDS dimension in the script using your specifications works just fine.


talk is cheap, supply exceeds demand