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

Button auto colourrchge

Hi , unable to work this out, but sure you can assist(: I have a number of button on the dashboard, I require then to change colour when a DATA exists in a dimension data field.

Dimension  - Analysis3 contain a list of 3 letter codes, if the code 'A34' exists the button changes colour1, if no code exists colour 2.

The button has a action set - when clicked it selects the code and lists, but I wish for the button to change colour without being selected, just to change colour when the dimension has a data code match.

Hop this make some sense! I can up load an example image of this. Thank you in anticipation(:

Labels (1)
5 Replies
anthonyj
Creator III
Creator III

Hi,

I hope I've understood correctly but you can try something like this in the color by expression.

=if(len(only({$<Analysis3={A34}>}Analysis3)) > 0, Green(), Red())

Logic:

The 'Only' function returns 'A34' if it's available otherwise it returns a null. 

The 'Len' (length) function will return 3 if it is found, so the condition will be true and return green. If it's null the condition is false and return red.

I hope this helps.

Thanks

Anthony

XCT300
Contributor II
Contributor II
Author

Hi Anthony, Thank you, so close, however a few mistakes on my part!

If data exists in the field/column of 'Description' then Green otherwise Red.

The buttons action refers to the Analysis Column 'Analysis3'  see image.

XCT300_0-1646474537384.png

As you can see all the buttons are named with 3 digits A01 all the way to Z99 (A lot), as the data builds in column Description (could be Code too) then the button changes colour and therefore shows the progress of areas have been covered (but not necessarily complete!).

Hopefully I have done a better job of explaining.

Many thanks for your assistance.

BJ

anthonyj
Creator III
Creator III

Hi @XCT300 ,

That is a lot of buttons. Since there are so many can offer a trick I've used before. 

Using the Treemap add the dimension Analysis3 and in the measure add avg({1<Analysis=>}1).  In the colors and legend, choose color by expression and add =if(len(Description)>0, Green(), Red())

Using the Treemap with the dimension will add all your Analysis titles to the tiles. Avg(1) will make the tiles the same size and the set analysis prevents the buttons from moving when interacting with the Analysis3 dimension.

anthonyj_0-1646622071526.png

It would be a lot quicker than creating so many buttons, each with their own set analysis for coloring.

Let me know how you go.

Thanks

Anthony

 

XCT300
Contributor II
Contributor II
Author

Thank you again, I am using Qlikview and not Qliksense, not sure if Treemap exits in Qlikview!

anthonyj
Creator III
Creator III

  I'm not proficient in Qlikview so I can't answer that one. I can give you the set analysis that would set the coloring for buttons based on the relevant description being populated or not though.

This is an example of returning whether there is a value  or not for "Description" of Analysis A19

if(len(only({$<[Analysis]={A19}, Description={"=len(Description)>0"}>} [Analysis])) > 0, Green(), Red())

Now given this would be a long and arduous task of copying, pasting and changing the "Analysis" value on every "Color by" expression, I've taken the liberty of providing two options to create variables that can be used in place of the set analysis.

The first loops through the distinct values in the "Analysis" column and creates a variable for each one that can be used. 

for i = 1 to FieldValueCount('Analysis')

    let vColor = FieldValue('Analysis', $(i));

    set vColor$(vColor) = if(len(only({$<[Analysis]={$(vColor)}, Description={"=len(Description)>0"}>} [Analysis])) > 0, Green(), Red());

next i;

let vColor=;
let i=;

Down side is that A01 to Z99, you will end up with a lot of variables so another way is to create a variable with a parameter. Here you'll only need one variable and you can add the button value you're after. For example, I've created a variable called vColorParam.

The syntax:

if(len(only({$<[Analysis]={$1}, Description={"=len(Description)>0"}>} [Analysis])) > 0, Green(), Red())

The $1 allows you to enter the value in the parameter so your color by expression would look like this.

=$(vColorParam(A20))

I hope something in here helps.

Thanks

Anthony