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

Announcements
Now accepting applications for the Qlik Luminary and Partner Ambassador Programs: Apply by July 6!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

WHERE field = X then FieldType?

Hello,

I have the following select statement,

SQL

SELECT Content,

CustomField,

    Disabled,

    ObjectId as id

FROM itsm.ObjectCustomFieldValues

WHERE CustomField = 4 OR CustomField = 5 OR CustomField = 7 OR CustomField = 8

AND Disabled = 0;

This statement works, but I need to take CustomField where it equals 4 or 7 and make it into a field called Category, and where CustomField equals 5 or 8 into a field called SubCategory.

Can this be done?

Labels (1)
1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Sure, something like this:

T1:

load Content,  CustomField,

if(CustomField = 4 or Customfield = 7, CustomField) as Category,

if(CustomField = 5 or Customfield = 8, CustomField) as SubCategory,

Disabled,

id;

SELECT Content,
CustomField,
    Disabled,
    ObjectId as id
FROM itsm.ObjectCustomFieldValues
WHERE CustomField = 4 OR CustomField = 5 OR CustomField = 7 OR CustomField = 8
AND Disabled = 0;


talk is cheap, supply exceeds demand

View solution in original post

2 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Sure, something like this:

T1:

load Content,  CustomField,

if(CustomField = 4 or Customfield = 7, CustomField) as Category,

if(CustomField = 5 or Customfield = 8, CustomField) as SubCategory,

Disabled,

id;

SELECT Content,
CustomField,
    Disabled,
    ObjectId as id
FROM itsm.ObjectCustomFieldValues
WHERE CustomField = 4 OR CustomField = 5 OR CustomField = 7 OR CustomField = 8
AND Disabled = 0;


talk is cheap, supply exceeds demand
Not applicable
Author

Thanks.  That worked!