Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
dmxmikey
Creator
Creator

Color Dimension result

Have the attached script that I would like to highlight results depended on result

Attached is my script

1 Solution

Accepted Solutions
jpenuliar
Partner - Specialist III
Partner - Specialist III

possibly this:

=if(aggr( Concat( DISTINCT if([ALL.alg-code]='PNUT',if([ALL.alg-stat]='N','N',if([ALL.alg-stat]='Y','Y',)),null()),'-'),[p-code],[PRODUCTS.p-desc],[PRODUCTS.p-size],PRODUCTS.origin)='N',RGB(255,0,0),

    if(aggr( Concat( DISTINCT if([ALL.alg-code]='PNUT',if([ALL.alg-stat]='N','N',if([ALL.alg-stat]='Y','Y',)),null()),'-'),[p-code],[PRODUCTS.p-desc],[PRODUCTS.p-size],PRODUCTS.origin)='Y',RGB(255,0,0),''))

basically, added another IF (expression is 'Y') then change bg color to Green, then at the end you have this part ,'')) which is any other result aside from  'N' and 'Y'.

View solution in original post

13 Replies
anbu1984
Master III
Master III

Attachment is missing

dmxmikey
Creator
Creator
Author

Here is the attachment sorry

Delivering the best in Foodservice...

dmxmikey
Creator
Creator
Author

Sorry am a bit new to scripting, basically what I need to do is for the results on the table its either a Y or N, so what i would like is to get the Y in a green background and N in red background.

Below is the script im using.

=aggr( Concat( DISTINCT

if([ALL.alg-code]='GLUT',if([ALL.alg-stat]='N','N',if([ALL.alg-stat]='Y','Y',)),null()),'-')

,[p-code],[PRODUCTS.p-desc],[PRODUCTS.p-size],PRODUCTS.origin)

stigchel
Partner - Master
Partner - Master

You already have a another thread open with almost the same question (script to return image if its a certain value) Instead of opening new threads with the same try to explain better what your problem is, with examples of what you have and what you need.

If this is your dimension(?) in e.g. a straight table(?) and you want different colors for the Y and N, click on the plus sign of the dimension and in Background color use this same expression, but instead of the Y and N use an rgb code.

=aggr( Concat( DISTINCT

if([ALL.alg-code]='GLUT',if([ALL.alg-stat]='N',rgb(255,0,0),if([ALL.alg-stat]='Y',rgb(0,255,0),)),null()),'-')

,[p-code],[PRODUCTS.p-desc],[PRODUCTS.p-size],PRODUCTS.origin)

dmxmikey
Creator
Creator
Author

What I would like is when I populate my report the results chow as below screenshot where Y is filled with green and N with red, have tried your example buy there is no is no change in color

Delivering the best in Foodservice...

stigchel
Partner - Master
Partner - Master

There is very little info for me to go on and you seem to have difficulties in explaining where the problem is.

In general you need an expression which results in a green or red color in the same way you determine whether it is a Y or N. This expression needs to be either in the background color of the dimension or the expression.

If you need more help then please post a sample of your qvw file, if you're worried about data sensitivity then please read this:

Preparing examples for Upload - Reduction and Data Scrambling

dmxmikey
Creator
Creator
Author

Thanks for that info, I have attached my qvw. And you will note on my dimension background I have put the script to color the Y in Green and N in red but the actual output is not colored.

Thanks Mike

Delivering the best in Foodservice...

jpenuliar
Partner - Specialist III
Partner - Specialist III

Hi Mike,

try the below code for peanuts at background color section of your calculated dimension

=if(aggr( Concat( DISTINCT

if([ALL.alg-code]='PNUT',if([ALL.alg-stat]='N','N',if([ALL.alg-stat]='Y','Y',)),null()),'-')

,[p-code],[PRODUCTS.p-desc],[PRODUCTS.p-size],PRODUCTS.origin)='N',RGB(255,0,0),RGB(0,255,0))

regards,

JP

stigchel
Partner - Master
Partner - Master

This should work for Gluten

=if(

aggr( Concat( DISTINCT

if([ALL.alg-code]='GLUT',if([ALL.alg-stat]='N','N',if([ALL.alg-stat]='Y','Y',)),null()),'-')

,[p-code],[PRODUCTS.p-desc],[PRODUCTS.p-size],PRODUCTS.origin)

='N',rgb(255,0,0),rgb(0,255,0)

)