Help with color coding report

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • Answered
Code:
Case([Contact Type], "No Longer with Firm", "#82BE41",
"Terminated Client", "#FFA07A",
"No Longer on the Engagement", "#E1EED9",
"Not a Current Client", "#42BCE8", "")


Error received:
Formula error -- Bad or missing arguments in function call

The types of the arguments or the number of arguments supplied do not meet the requirements of the function Case.

The function is defined to be Case ( x, val1,result1, ..., else-result).

You may need to do one of the following to fix the problem:
  • Choose the right number and type of arguments.
  • Use a type conversion function to convert the arguments you are using to the correct type.
  • Choose a different function
Photo of Mark Comish

Mark Comish

  • 790 Points 500 badge 2x thumb

Posted 1 year ago

  • 0
  • 1
Can you tell us what field type is [Contact Type]

Maybe it is a multi-select field?
Photo of Mark Comish

Mark Comish

  • 790 Points 500 badge 2x thumb
Yes it is a multi select text

Mark
Try this
var text ContactTypeInTextFormat = ToText([Contact Type]);

IF(
Contains($ContactTypeInTextFormat, "No Longer with Firm"), "#82BE41",
Contains($ContactTypeInTextFormat,"Terminated Client"), "#FFA07A",
Contains($ContactTypeInTextFormat,"No Longer on the Engagement"), "#E1EED9",
Contains($ContactTypeInTextFormat,"Not a Current Client", "#42BCE8"))
Note that since more than 1 value can selected, the first one which is true will "win".
Photo of Mark Comish

Mark Comish

  • 790 Points 500 badge 2x thumb
It gave me this error...

Formula error -- Bad or missing arguments in function call

The types of the arguments or the number of arguments supplied do not meet the requirements of the function Contains.

The function is defined to be Contains (Text u, Text v).

You may need to do one of the following to fix the problem:
  • Choose the right number and type of arguments.
  • Use a type conversion function to convert the arguments you are using to the correct type.
  • Choose a different function.
Hmmm, and you exactly pasted in the formula above?  Can I see your exact formula? 
Photo of Mark Comish

Mark Comish

  • 790 Points 500 badge 2x thumb
var text ContactTypeInTextFormat = ToText([Contact Type]);

If(
Contains($ContactTypeInTextFormat, "No Longer with Firm"), "#82BE41",
Contains($ContactTypeInTextFormat,"Terminated Client"), "#FFA07A",
Contains($ContactTypeInTextFormat,"No Longer on the Engagement"), "#E1EED9",
Contains($ContactTypeInTextFormat,"Not a Current Client", "#42BCE8"))
Photo of Mark Comish

Mark Comish

  • 790 Points 500 badge 2x thumb
I got it!  Thanks just needed to move a )
OK, I see my error now n the last line.

Contains($ContactTypeInTextFormat,"Not a Current Client"), "#42BCE8")
Photo of Lisa

Lisa

  • 340 Points 250 badge 2x thumb
The Case statement doesn't need the final clause - this is all you need to do:
Case([Contact Type], "No Longer with Firm", "#82BE41",
"Terminated Client", "#FFA07A",
"No Longer on the Engagement", "#E1EED9",
"Not a Current Client", "#42BCE8")
Photo of Mark Comish

Mark Comish

  • 780 Points 500 badge 2x thumb
It gave this error, probably because Contact Type is a multi select text...

Formula error -- Bad or missing arguments in function call

The types of the arguments or the number of arguments supplied do not meet the requirements of the function Case.

The function is defined to be Case ( x, val1,result1, ..., else-result).

You may need to do one of the following to fix the problem:
  • Choose the right number and type of arguments.
  • Use a type conversion function to convert the arguments you are using to the correct type.
  • Choose a different function.