Select to view content in your preferred language

Dashboard - Conditional Formatting on Table using multiple Keywords from the same field.

478
3
Jump to solution
07-28-2024 10:26 AM
LindsayLewin
Occasional Contributor

Hello.

I have a table where I would like to highlight entire rows different colors based on 3 choices from the same field.

I have one choice highlighted, but not sure how to include the other two, which would have a different highlight.  Any suggestions would be appreciated.

Here is a little snapshot of my code

 

// Highlight descriptions with a keyword
var keyword = 'DAC';
// Use Find() to determine the index of the word
var hasKeyword = Find(keyword, Upper($datapoint["Status"])) >= 0;
// Update text and background colors if it has the keyword

return {
  cells: {
    GridID: {
      displayText : Text($datapoint.GridID),
      textColor: IIF(hasKeyword, '#000000', ''),
      backgroundColor: IIF(hasKeyword, '#BDD7EE', ''),
      textAlign: 'center',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''

 

0 Kudos
1 Solution

Accepted Solutions
Davide_Pili
New Contributor

Hi LindsayLewin

 

I hope I understood your request well.
Try this Arcade code:

 

var highlight = ''
var colorText =''

if($datapoint.Status== 'DAC'){
  highlight = '#89ac76'
  colorText = '#ffffff'
}

if ($datapoint.Status == 'Staked'){
  highlight= '#3d642d'
  colorText = '#ffffff'
}

return {
  cells: {
    GRID_ID: {
      displayText : Text($datapoint.GRID_ID),
      textColor: colorText,
      backgroundColor: highlight,
      textAlign: 'right',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
   
    Status: {
      displayText : $datapoint.Status,
      textColor: colorText,
      backgroundColor: highlight,
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
   
    Seeded: {
      displayText : Text($datapoint.Seeded),
      textColor: colorText,
      backgroundColor: highlight,
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
   
    seedDepth: {
      displayText : Text($datapoint.seedDepth),
      textColor: colorText,
      backgroundColor: highlight,
      textAlign: 'right',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    }
  }
}Immagine 2024-07-29 095405.png

View solution in original post

0 Kudos
3 Replies
Davide_Pili
New Contributor

Hi LindsayLewin

 

I hope I understood your request well.
Try this Arcade code:

 

var highlight = ''
var colorText =''

if($datapoint.Status== 'DAC'){
  highlight = '#89ac76'
  colorText = '#ffffff'
}

if ($datapoint.Status == 'Staked'){
  highlight= '#3d642d'
  colorText = '#ffffff'
}

return {
  cells: {
    GRID_ID: {
      displayText : Text($datapoint.GRID_ID),
      textColor: colorText,
      backgroundColor: highlight,
      textAlign: 'right',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
   
    Status: {
      displayText : $datapoint.Status,
      textColor: colorText,
      backgroundColor: highlight,
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
   
    Seeded: {
      displayText : Text($datapoint.Seeded),
      textColor: colorText,
      backgroundColor: highlight,
      textAlign: 'left',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    },
   
    seedDepth: {
      displayText : Text($datapoint.seedDepth),
      textColor: colorText,
      backgroundColor: highlight,
      textAlign: 'right',
      iconName: '',
      iconAlign: '',
      iconColor: '',
      iconOutlineColor: ''
    }
  }
}Immagine 2024-07-29 095405.png
0 Kudos
LindsayLewin
Occasional Contributor

This worked great!  

Thank you!

Lindsay

0 Kudos
AmySnelgrove1
Emerging Contributor
Ignore! I figure out my mistake!
0 Kudos