Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
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?

1 Solution

Accepted Solutions
Gysbert_Wassenaar

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

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!