Jump to content

Two different choices of colors following a rule in a table


Jlary
Go to solution Solved by David Boot-Olazabal,

Recommended Posts

Posted (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.

2024-05-07 09_58_49-Analyse TSP - TIBCO Spotfire.png

Edited by Jlary
Link to comment
Share on other sites

  • Solution

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:
image.thumb.png.3d74c8a5a83ae8f2edc633947e5382a2.png

Kind regards,

David

Link to comment
Share on other sites

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% :

image.png.1229b346869b44460a4a8c4cd48dc713.png

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

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

  • 2 weeks later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...