Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
morenoju
Partner - Specialist
Partner - Specialist

Field not found / CASE WHEN in Load Script

Hi all,

I have a field in my DB called is_planned that can be a 1, meaning planned, or a 0, meaning unplanned.

As I don't want users to have to remember the codes (1 for this, 0 for that) I thought of using a CASE WHEN in the load script, like this:

[event_type]:

LOAD

[event_type_id],

[name] AS [event_type.name],

[event_category_id],

[is_planned];

SQL SELECT "event_type_id",

"name",

"event_category_id",

CASE WHEN "is_planned" = 1 THEN 'Planned' ELSE 'Unplanned' END

FROM "pems"."public"."event_type";

It is giving me the following error when loading:

The following error occurred:

Field 'is_planned' not found

The error occurred here:

?

I used the CASE WHEN in my load scripts before issue without. Do you see what might be wrong this time?

Also, if you think there's a better way to obtain the same result, don't hesitate to comment.

Thanks in advance!

1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

Try this

[event_type]:

LOAD [event_type_id],

    [name] AS [event_type.name],

    [event_category_id],

    [is_planned];

SQL SELECT

    "event_type_id",

    "name",

    "event_category_id",

    CASE WHEN "is_planned" = 1 THEN 'Planned' ELSE 'Unplanned' END AS "is_planned"

FROM "pems"."public"."event_type";

View solution in original post

4 Replies
sunny_talwar
MVP
MVP

Try this

[event_type]:

LOAD [event_type_id],

    [name] AS [event_type.name],

    [event_category_id],

    [is_planned];

SQL SELECT

    "event_type_id",

    "name",

    "event_category_id",

    CASE WHEN "is_planned" = 1 THEN 'Planned' ELSE 'Unplanned' END AS "is_planned"

FROM "pems"."public"."event_type";

morenoju
Partner - Specialist
Partner - Specialist
Author

Thanks Sunny!

That was it!

agigliotti
MVP
MVP

OR

[event_type]:

LOAD

[event_type_id],

[name] AS [event_type.name],

[event_category_id],

if( [is_planned] = 1, 'Planned', 'Unplanned' ) as [is_planned];

SQL SELECT

"event_type_id"

"name",

"event_category_id",

"is_planned"

FROM "pems"."public"."event_type";

The Power of shining a light on the dark side of your data.
Follow me on my LinkedIn | Know Gamma Informatica at gammainformatica.it
morenoju
Partner - Specialist
Partner - Specialist
Author

Thanks Andrea!