Search code examples
cognoscognos-10cognos-bicognos-11cognos-8

IBM Cognos IF/casewhen + _days_between


I have a liste of value and when a value = something i want it to calcultate a number of day between 2 dates. Error: "QE-DEF-0459 CCLException Incompatible data types in CASE statements"

Exemple: CASE WHEN ([Statut dossier] = 'Att 1 sv') THEN (_days_between (current_date;[Date start])) ELSE (0) END

I tried with IF, something like that: IF ([Statut dossier] = 'Att 1 sv') THEN (_days_between (current_date;[Date start]) ELSE ('0')


Solution

  • Since the error message mentions data types your first investigation should be of the data types of the things in the expression and the expression itself.

    You will notice that you want a value of the days between two dates to be returned if your Statut dossier = 'Att 1 sv' but you want a string if isn't. Days between returns an integer, which is not compatible with strings.

    So assuming that you want numeric values you would need to remove the ('0') and substitute (0). Assuming you want the result of the expression to be strings then you would need to cast the result of the days between expression to make it compatible with the else result. I'm guessing you want the former rather than the latter.

    You will need to verify the usage of the expression as well, once you've gotten past this hurdle. You would need to determine if this is a measure or an attribute.