Jlary Posted May 7 Share Posted May 7 (edited) Good morning, I am working on a dashboard and I would like to add colors to it according to certain conditions. 1st condition: if the Evol N N-1% column is > 0 then I color in red and green for the rest, IF call classification = CARENCE 2nd condition: if the Evol N N-1% column is > 0 then I color in green and red for the rest, IF call classification = EXTREME EMERGENCE Is it possible ? Thanks in advance. Edited May 7 by Jlary Link to comment Share on other sites More sharing options...
Solution David Boot-Olazabal Posted May 7 Solution Share Posted May 7 Hi Jlary, Color coding based on expressions is possible in Spotfire. Having said that, I'm not sure if I follow the proposed logic and the color coding in the screenshot. The first condition is "if the Evol N N-1% column is > 0 then I color in red and green for the rest, IF call classification = CARENCE". To me, that means that whenever the classification is CARENCE and the Evol N N-1% is greater than 0, the color should be red. Else it should be green. This matches the coding, since the Evol N N-1% is smaller than 0. But the second condition "if the Evol N N-1% column is > 0 then I color in green and red for the rest, IF call classification = EXTREME EMERGENCE ", I would have expected the same green color, since the Evol N N-1% is greater than 0 and the classification is EXTREME EMERGENCE (which matches the condition and the color should be green). Is there a typo in one of the 2 conditions or your example perhaps? In any case, no matter how your conditions would look like, I would advise to create a calculated column that looks like this: CASE WHEN ([Classification]="CARENCE") AND ([Evol N N-1%]>0) THEN "RED" WHEN ([Classification]="EXTREME URGENCE") AND ([Evol N N-1%]>0) THEN "RED" ELSE "GREEN" END You can use this column to color code the two Evol columns, using the next set up: Kind regards, David Link to comment Share on other sites More sharing options...
Jlary Posted May 7 Author Share Posted May 7 Thank you for your reply. I understand what needs to be done but I think that the way I constructed the table does not allow it to be achieved. I created two calculated columns N and N-1: N : If([Year]=integer(Year(Today())),1,0) N-1 : If([Year]=integer(Year(Today()) - 1),1,0) My file is in this form: Code Intervention classification appel date Year N N-1 0001 CARENCE 24/01/2023 2023 0 1 0002 EXTREME URGENCE 24/02/2023 2023 0 1 0003 CARENCE 24/03/2023 2023 0 1 0004 CARENCE 24/04/2023 2023 0 1 0005 EXTREME URGENCE 24/06/2023 2023 0 1 0006 CARENCE 24/02/2024 2024 1 0 0007 EXTREME URGENCE 24/03/2024 2024 1 0 0008 EXTREME URGENCE 24/04/2024 2024 1 0 0009 CARENCE 24/05/2024 2024 1 0 0010 EXTREME URGENCE 24/06/2024 2024 1 0 So I sum the columns to get my value per month. Here is my calculation for Evol N N-1% : The calculation of this new calculated column is therefore not possible : CASE WHEN ([Classification]="CARENCE") AND ([Evol N N-1%]>0) THEN "RED" WHEN ([Classification]="EXTREME URGENCE") AND ([Evol N N-1%]>0) THEN "RED" ELSE "GREEN" END I hope you understand. Link to comment Share on other sites More sharing options...
David Boot-Olazabal Posted May 7 Share Posted May 7 Hi, I think you should be able to use the calculated column Evol N N-1% in another calculated column. If the classification doesn't have a real impact, the color coding case statement can be a lot easier: CASE WHEN [Evol%]>0 THEN 'RED' ELSE 'GREEN' END I have tried to use your data in a dashboard, but made some changes in the N and N-1 columns to see be able to better see the differences. I have, in attached dashboard, used a table and cross table to implement the color coding. Kind regards, David ColorCoding.dxp Link to comment Share on other sites More sharing options...
Jlary Posted May 7 Author Share Posted May 7 I have version 12.0.1.41, I cannot read your file because my version cannot read version 14 files. Link to comment Share on other sites More sharing options...
David Boot-Olazabal Posted May 7 Share Posted May 7 Ah right, I'll try to replicate this dashboard in that version. Kind regards, David Link to comment Share on other sites More sharing options...
David Boot-Olazabal Posted May 8 Share Posted May 8 Hi, Please find the dashboard in SF12 attached. Kind regards, David ColorCoding.dxp Link to comment Share on other sites More sharing options...
Jlary Posted May 17 Author Share Posted May 17 Hi, I succeeded using this expression : case when (first([classification appel] in ("CARENCE", "EXTREME URGENCE"))=True) and ((Sum([N]) - Sum([N-1]))<0) then "red" when (first([classification appel] in ("CARENCE", "EXTREME URGENCE"))=True) and ((Sum([N]) - Sum([N-1]))>=0) then "green" when (first([classification appel] not in ("CARENCE", "EXTREME URGENCE"))=True) and ((Sum([N]) - Sum([N-1]))<0) then "green" when (first([classification appel] not in ("CARENCE", "EXTREME URGENCE"))=True) and ((Sum([N]) - Sum([N-1]))>=0) then "red" end Thanks for your help. Julien Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now