Select to view content in your preferred language

Combine multiple values to color values using expressions

486
0
07-28-2021 11:18 AM
Labels (1)
JoseBarrios1
Frequent Contributor

Hello everyone,

I have a category field that I want to display on a dashboard list with different background colors (div) for each category.  For example: I have a field called “Project_status” and the categories are:

1.Completed,

2.Proposed,

3.In-progress,

4.Under-Review,

5.Funded,

6.Canceled,

7.Incomplete,

8. Extended, 

9.Approved.  

What I want to accomplish is to color “Completed”, “Canceled” and “Incomplete” with a GREEN background color, “In-progress” and “Under-Review” as ORANGE and else as GRAY background color.  I don’t want to create a new field just to combine the categories and I’m trying to build an expression to combine the values.  I was able to create an expression ( I'm just learning)  for coding a color for each category but I’m not sure how to ‘group” multiple categories to assign the same color code. Below is a sample of the expression I created. (I also created a HTML style using <div style="background-color: {expression/ backCardColor} </div> to assign the background color.) .   If you have any suggestions, please let me know. Thanks !

********************************************************

Var prjStatus= $datapoint["Project_Status"];

if (prjStatus == 'Under-Review') {  //... I need to add “In-progress” to have the same color.

return {      

  backgroundColor: '',

  selectionTextColor: 'da687b',

  attributes: {

        backCardColor: '#f6deb1',

         }  

 }

}

else (prjStatus == 'Completed') {    // I need to add “Canceled” and “Incomplete” to have the same color…

return {      

  backgroundColor: '',

  selectionTextColor: 'da687b',

  attributes: {

        backCardColor: '#dee7d5',

         }  

 }

}

 else {

   return {      

  backgroundColor: '',

  selectionTextColor: 'da687b',

  attributes: {

    backCardColor: '#dfe1e3',

         } 

 }

0 Kudos
0 Replies