Skip to main content

I am working on a project for school and keep running into the error: "Expected type float, found string. Result types from 'CASE' expressions must match."

 

What am I missing here? Here is my code:

 

CASE [p. Measure]

WHEN "Asset Turnover" THEN [Asset Turnover]

WHEN "Contribution Margin" THEN [Contribution Margin]

WHEN "Cumulative Profit" THEN [Cumulative Profit]

WHEN "Market Share (Actual)" THEN [Market Share (Actual)]

WHEN "Leverage" THEN [Leverage]

WHEN "Profit" THEN [Profit]

WHEN "ROA" THEN [ROA]

WHEN "ROE" THEN [ROE]

WHEN "ROS" THEN [ROS]

WHEN "Sales" THEN [Sales]

END

3 answers
  1. Nov 25, 2023, 7:46 PM

    Just guessing, because we have nothing but the code provided to really be able to tell, but one of those fields in your code is likely cast as 'abc' (look for the icon next to each field, it will tell you what it's cast as...) which would be text or string. So the case statement is evaluating that and seeing that something (one of the fields, or more of them) isn't really float (Measure), but is something else. You'll need to fix that by either removing the line from the code that pertains to the string (abc/text) and/or modifying the string to be float. You can always use the // double-forward slash to at the beginning of a particular line of the code (in front of a particular WHEN statement) to comment out the code. That will suppress the particular line of the code to test which of the items in the list is the problem.

     

    Best, Don

    (Please, don't forget to click Select as Best or Upvote !)

0/9000