Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expression help in text Object

Hi,

I have the below expression which i need to show the RAG status in the Text object. I am not sure how to write the below exp for the RAG status.

=ceil(count(if ([status]=1,Employee))/count(if([status]='1','0',Employee))

(i.e, count of EMPLOYEES when STATUS=1 divided by Count of EMPLOYEES when STATUS=1 and 0)

RAG should be:

0-75 Red
75-85 Amber
85-100 Green

I want to use images 'qmem://<bundled>/BuiltIn/led_r.png', 'qmem://<bundled>/BuiltIn/led_y.png', 'qmem://<bundled>/BuiltIn/led_g.png' for Red, Amber and Green.

Can anyone help me out please?

Thanks

1 Solution

Accepted Solutions
Gysbert_Wassenaar

You're correct. Try this one:

=If(Ceil(count({<status={1}>} Employee) / count({<status={0,1}>} Employee)) < 75,

'qmem://<bundled>/BuiltIn/led_r.png',

  If(Ceil(count({<status={1}>} Employee) / count({<status={0,1}>} Employee)) < 85,

   'qmem://<bundled>/BuiltIn/led_y.png',

    'qmem://<bundled>/BuiltIn/led_g.png'

  )

)


talk is cheap, supply exceeds demand

View solution in original post

9 Replies
Aurelien_Martinez
Partner - Specialist II
Partner - Specialist II

Hi,

=If(Ceil(count({<status=1>} Employee) / count({<status=0>} Employee) < 75,

'qmem://<bundled>/BuiltIn/led_r.png',

  If(Ceil(count({<status=1>} Employee) / count({<status=0>} Employee) < 85,

   'qmem://<bundled>/BuiltIn/led_y.png',

    'qmem://<bundled>/BuiltIn/led_g.png'

  )

)

Help users find answers! Don't forget to mark a solution that worked for you!
Not applicable
Author

Hi Aurien,

Thanks for your reply. I need to count both 1 and 0 in the denominator but in your expression its just counting Status=0. Is your expression correct ?

Thanks

Gysbert_Wassenaar

=If(Ceil(count({<status={1}>} Employee) / count({<status={0,1}>} Employee)) < 75,

'qmem://<bundled>/BuiltIn/led_r.png',

  If(Ceil(count({<status={1}>} Employee) / count({<status={0,1}>} Employee)) < 85,

   'qmem://<bundled>/BuiltIn/led_y.png',

    'qmem://<bundled>/BuiltIn/led_g.png'

  ))


talk is cheap, supply exceeds demand
Not applicable
Author

info(if(count({<Status={1}>}Employee)/count({<Status={0,1}>}Employee)<=75,

'qmem://<bundled>/BuiltIn/led_r.png',

if(count({<Status={1}>}Employee)/count({<Status={0,1}>}Employee)<=85,

'qmem://<bundled>/BuiltIn/led_y.png',

'qmem://<bundled>/BuiltIn/led_g.png' )))


try this

Not applicable
Author

Hi wasseaar,

I tried your expression but getting 'error in expression'. Might be somewhere brackets are missing.

here is my expression:

 

=If(ceil(count({<[status]={1}>} Employee) / count({<[status]={0,1}>} Employee) < 75,'qmem://<bundled>/BuiltIn/led_r.png'
,
If(ceil(count({<[status]={1}>} Employee) / count({<[status]={0,1}>} Employee) <85, 'qmem://<bundled>/BuiltIn/led_y.png','qmem://<bundled>/BuiltIn/led_g.png'))

I try to add 2 closed brackets at the end of the expression but still getting error in expression. could you check it for me please?

Thanks


Gysbert_Wassenaar

You're correct. Try this one:

=If(Ceil(count({<status={1}>} Employee) / count({<status={0,1}>} Employee)) < 75,

'qmem://<bundled>/BuiltIn/led_r.png',

  If(Ceil(count({<status={1}>} Employee) / count({<status={0,1}>} Employee)) < 85,

   'qmem://<bundled>/BuiltIn/led_y.png',

    'qmem://<bundled>/BuiltIn/led_g.png'

  )

)


talk is cheap, supply exceeds demand
Not applicable
Author


thanks Wassenaar. Working fine now. I need one more clarification. I created an object with below expression.

  =ceil(count(if ([status]=1,Employee))/ count(if([status]='1','0',Employee))

I am not sure whether my expression is correct or not. My requirement is to Count all the employees who are in status 1, divided by, count of all employees who re in status 1 and 0. Is there any otherway to write the above expression  ?

Thanks

Gysbert_Wassenaar

It's not correct. This would be:  =ceil(count(if ([status]=1,Employee))/ count(if([status]=1 or [status]= 0,Employee))

You could also write it like this:

=ceil(count({<[status]={1}>}Employee)/count({<[status]={1,0}>}Employee))

On large datasets this would perform better than the expression with the if statements


talk is cheap, supply exceeds demand
Not applicable
Author


Excellent, I tried the 2nd one (the one without the If statement) and is working fine. Many thanks!