You can translate the question and the replies:

Creating new field in derived view using conditional logic

Hello. I have created a derived view named 'dv_1' based on a base view named bv_1. I need to create a new column named 'new_col' in the derived view 'db_1' using conditional logic. The values in the new column 'new_col' depend on the values of two another columns that are found in the base view 'bv_1' named 'cd' and 'amt'. If the value in the 'cd' column equals 'c', then the values in the 'new_col' column should equal the value in the 'amt' column times -1. Otherwise, if the value in the 'cd' column equals 'd', then the value in the 'new_col' column should equal the value in the 'amt' column as is. This is what I have entered in the 'Field expression: case when = 'c' then dv_1.new_col = bv_1.amt * -1 else dv_1.new_col = bv_1.amt end However, I get the following error message: Couldn't repari and continue parse(near character 110) Any help would be greatly appreciated. Thank you.
20-12-2022 19:15:35 -0500

2 Answers

Hi, I too got the same error ”**Couldn’t repari and continue parse**” while entering the case Clause in the field expression with the specified format. I would use the below syntax in the field expression to avoid this error: Syntax: > CASE WHEN <condition> THEN result [ WHEN <condition> THEN result ...] [ ELSE result ] END For the result part of the syntax you have specified the condition <column_name>=<value> but it would expect only the <**value**> part as per the syntax. For Example: > case WHEN ( = 'c') > THEN (amt*-1) > ELSE amt > END You could look at to the [**CASE Clause**]( section of the Virtual DataPort VQL Guide for further information about the syntax of a case statement. Hope this helps!
Denodo Team
21-12-2022 04:14:40 -0500
It worked. Thank you very much!
21-12-2022 10:13:57 -0500
You must sign in to add an answer. If you do not have an account, you can register here