Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

cancel
Showing results for 
Search instead for 
Did you mean: 
akpofureenughwu
Creator III
Creator III

If statement

Hello sir,

I need to do an statement for a set of data like this

if(count({$<[Project Status] = {'Completed'} >}Community)  /Count(Community)>=0.9,Green(),   

if(count({$<[Project Status] = {'Completed'} >} Community)  /Count(Community)<0.9,LightGreen(),

if(count({$<[Project Status] = {'Completed'} >} Community)  /Count(Community)<0.5, Blue()

if(count({$<[Project Status] = {'Completed'} >} Community)  /Count(Community)<0.5,Red()))))

but it's not give me the desired result.

Regards

1 Solution

Accepted Solutions
sunny_talwar

May be try this

if(count({$<[Project Status] = {'Completed'} >} Community)  /Count(Community)<=0.49,Red(),

if(count({$<[Project Status] = {'Completed'} >} Community)  /Count(Community)<0.5, Blue(),

if(count({$<[Project Status] = {'Completed'} >} Community)  /Count(Community)<0.9,LightGreen(), Green())))

View solution in original post

4 Replies
sunny_talwar

The last two conditions look the same, is that on purpose?

Capture.PNG

akpofureenughwu
Creator III
Creator III
Author

Sorry sir,

if(count({$<[Project Status] = {'Completed'} >}Community)  /Count(Community)>=0.9,Green(),   

if(count({$<[Project Status] = {'Completed'} >} Community)  /Count(Community)<0.9,LightGreen(),

if(count({$<[Project Status] = {'Completed'} >} Community)  /Count(Community)<0.5, Blue()

if(count({$<[Project Status] = {'Completed'} >} Community)  /Count(Community)<=0.49,Red()))))

sunny_talwar

May be try this

if(count({$<[Project Status] = {'Completed'} >} Community)  /Count(Community)<=0.49,Red(),

if(count({$<[Project Status] = {'Completed'} >} Community)  /Count(Community)<0.5, Blue(),

if(count({$<[Project Status] = {'Completed'} >} Community)  /Count(Community)<0.9,LightGreen(), Green())))

Peter_Cammaert
Partner
Partner

If we assume that IF() functions are evaluated in sequence, this expression only produces two colors:

  • Green for everything larger than or equal to 0.9
  • Lightgreen for everything smaller than 0.9

The other expressions won't be evaluated because there will always be a match in the first two IF() calls.

Reorder your expression as:

IF (expr <= 0.49, Red(),

    if (expr < 0.5, Blue(),

        if (expr < 0.9, Lightgreen(),

            Green())))


You may want to change the border values for the first two tests, because the blue color range will only match 0.49 < x < 0.5