1 2 Previous Next 16 Replies Latest reply on Sep 13, 2018 8:21 PM by Anisha Jhamb

# Expected type string, found integer.  Comparison in 'CASE' expression must be string type.

Can someone help me fix this Calculated Field?

CASE [Case Distributions, Backlog & Closures Picker]

WHEN 1 THEN [Assigned to CSR GMT] >= DATE([DATEADD('hour',7,NOW())])

WHEN 2 THEN DATE([Assigned to CSR GMT]) = DATE([DATEADD('hour',7,NOW())])-1

WHEN 3 THEN STR([CLOSEDDATE_GMT]) = NULL

END

The error message states, that the comparison in 'CASE' expression must be string type however, I've seen calculations like the one below work.

CASE [Sum of Profit or Sum of Sales Picker]

WHEN 1 THEN SUM([Profit])

WHEN 2 THEN SUM([Sales])

END

Can you someone help me understand how to fix my calculation?

• ###### 1. Re: Expected type string, found integer.  Comparison in 'CASE' expression must be string type.

Is this field [Case Distributions, Backlog & Closures Picker]  in string or integer format?

1 of 1 people found this helpful
• ###### 2. Re: Expected type string, found integer.  Comparison in 'CASE' expression must be string type.

You are Trying To say That if Whatever in yellow is 1, 2 or 3 then do that. If Highlighted value Returns String How you will Compare unless you have the Values 1,2,3  as String there.

1 of 1 people found this helpful
• ###### 3. Re: Expected type string, found integer.  Comparison in 'CASE' expression must be string type.

I recreated the scenario with SuperStore example:

1 of 1 people found this helpful
• ###### 4. Re: Expected type string, found integer.  Comparison in 'CASE' expression must be string type.

Anisha..Is this calculation Returning you values?

• ###### 5. Re: Expected type string, found integer.  Comparison in 'CASE' expression must be string type.

It will return values, if the value in field matches with the value preceding WHEN keyword. In my case, Order ID has alphanumeric values, hence, it will not give output because the WHEN clause has numbers.

I agree with you that in Manuel's scenario, the values in the field [Case Distributions, Backlog & Closures Picker] must be 1,2,3 (defined in WHEN clause) even if the format is string. And, INT([Case Distributions, Backlog & Closures Picker]) can be used to align the data types.

1 of 1 people found this helpful
• ###### 6. Re: Expected type string, found integer.  Comparison in 'CASE' expression must be string type.

Hi Anisha,

In response to ...

Q: "Is this field [Case Distributions, Backlog & Closures Picker]  in string or integer format?"

A: this field [Case Distributions, Backlog & Closures Picker] is a String List Parameter.  So this calculation contains [Case Distributions, Backlog & Closures Picker] parameter.

After you asked me about Data Type of the Parameter field, I quickly realized that I had entered my Parameter Values as string names (such as Assigned to CSR Today GMT, etc.) in the "List of Values" field.  I should have entered integer Values 1, 2, 3 as I had referred these Values in my Calculation by integer instead of by string names (such as Assigned to CSR Today GMT, etc.).

Because of this error the calculation did not recognize integer Values in the Parameter because the Parameter referred to the Values by string names (such as Assigned to CSR Today GMT, etc.) instead of integer Values.

This question helped me understand that the issue with the calc field was in the Data Type as well as List of Values selections I made while creating the Parameter.

Thank you so much for your help with this an my other question!

Manuel

• ###### 7. Re: Expected type string, found integer.  Comparison in 'CASE' expression must be string type.

Hi Deepak ... correct, trying to say that if whatever is in yellow (the Parameter) 1, 2 or 3 then execute that that calculation.

Initial error message was: Expected type string, found integer. Comparison in 'CASE' expression must be string type.  Even though my 'CASE' expression Parameter [Case Distributions, Backlog & Closures Picker] was already a String, I ended up changing the Parameter Data Type from String to Integer as well as changing Values (such as Assigned to CSR Today GMT, etc.) to 1,2,3 and the Calculation is now valid.

FROM:

TO:

Thank you so much for your help with this question!

• ###### 8. Re: Expected type string, found integer.  Comparison in 'CASE' expression must be string type.

Please consider marking the replies as Correct/Helpful as appropriate on the discussions. This helps anyone who may be looking for a solution to a similar problem.

Thanks!

• ###### 9. Re: Expected type string, found integer.  Comparison in 'CASE' expression must be string type.

Good, It Worked for you and That's the way it was expected to work. You may Close Thread if you got what was needed.

Thanks

Deepak

• ###### 10. Re: Expected type string, found integer.  Comparison in 'CASE' expression must be string type.

Hi Anisha ... Thanks for recreated the scenario with SuperStore.

Even though my 'CASE' expression Parameter was already a String Data type (as you can see from the Parameter print screen below) I converted the 'CASE' expression Parameter in the Calc Field using INT() and the calculation is now valid.

CASE INT([Case Distributions, Backlog or Closures Picker])

However not sure I understand the error message which stated, "Expected type string, found integer.  Comparison 'CASE' expression must be a string type."  I created the Parameter as a string, which is what was expected according to the error msg.  But then in the Calc Field I converted the  'CASE' expression to INT:  CASE INT([Case Distributions, Backlog or Closures Picker]) which doesn't make scene to me since the Parameter used in the 'CASE' expression was created as a String to begin with.  Why does it need to be converted to INT in the Calc Field when according to the error message the expected type is string and that is what was created? Any guidance with this part of the question would be greatly appreciated. Thank you.

Converted 'CASE' expression to INT below and the Calc is now valid, even though the error message stated that the expected type is string and that is what was created?

CASE INT([Case Distributions, Backlog or Closures Picker])

• ###### 11. Re: Expected type string, found integer.  Comparison in 'CASE' expression must be string type.

Thanks for this input also.  I learned that for my scenario, I can change the Parameter's Data Type to

Integer ...

... and when I do then I do not have to convert the 'CASE' expression into INT().

• ###### 12. Re: Expected type string, found integer.  Comparison in 'CASE' expression must be string type.

Thanks again Deepak!

• ###### 13. Re: Expected type string, found integer.  Comparison in 'CASE' expression must be string type.

You are Welcome!!! One Suggestion though, you struggled all day for this. This could have been Solved much earlier with a packaged workbook with fake data set.

Thanks

Deepak

• ###### 14. Re: Expected type string, found integer.  Comparison in 'CASE' expression must be string type.

Oh I see, got it.  Thanks again for all the valuable tips and info. -Manuel

1 2 Previous Next