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

IF AND

 

I have a QV app with a Text field.

I want to change the font color based on a filter.

If i select the filter 'Technology' as '1' or '2' or '3' the color should be green.

If i select '1' AND '2' it should be red

I used this expression bet it doesn't work  (shows green no matter what filter value I use)

=If (Technology='1' and Technology='2' , v_rgb_red, v_rgb_green)

16 Replies
sunny_talwar

So, all 3 selected together it should be green? If only 3G is selected? or 3G and 4G selected?

stekol61
Creator
Creator
Author

Yes, only 2G, 3G and 4G should be green.

Single value or any other combination, e.g 3G and 4G, should be red

sunny_talwar

So, then try this

If(Concat(DISTINCT Technology, '|') = '2G|3G|4G', Green(), Red())
Kushal_Chawda

@stekol61  Just another option in case your field is not sorted and concat values sequence does not match with hard coded value then for safer side check condition for individual values so that it will work always

=if(wildmatch(GetFieldSelections(Technology),'*2G*') and wildmatch(GetFieldSelections(Technology),'*3G*')  and wildmatch(GetFieldSelections(Technology),'*4G*') ,green(),red())

  

stekol61
Creator
Creator
Author

THX, this solved my problem

sunny_talwar

@Kushal_Chawda why not add a sort parameter for this instead? Have not tested it, but the idea is to give a sort for the Concat function.

If(Concat(DISTINCT Technology, '|', -Rank(Technology)) = '2G|3G|4G', Green(), Red())

 

Kushal_Chawda

@sunny_talwar  Yes. We can give it. I  just  used another method instead without depending on the sorting.