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: 
jleefjcapital
Creator II
Creator II

Using "if statement" in load statement

I am using a panel dataset which contain two separate categories.  I would like to separate out by one of the categories.  For instance,  I have one category which is region, and the other as employment type.  I would like to write an if statement to only load the regions for a single employment type.  I tried using the following, but it keeps causing an error- "Field not found"   I think this statement implies that "management_occupations" is a field, but it's a value.  How should I change this so that it only pulls the regions where OCC_TITLE = "Management_Occupations"?

Thank you.

LOAD

    AREA_NAME as MSA,

    "LOC QUOTIENT" as LQ_MSA,

    H_MEDIAN,

    If("OCC_TITLE" = [Management Occupations], "OCC_TITLE", NULL) as Management_Occupation

FROM [lib://Employment/MSA_M2014_dl.xlsx]

(ooxml, embedded labels, table is MSA_dl);

Labels (1)
1 Solution

Accepted Solutions
swuehl
Champion III
Champion III

Try

LOAD

    AREA_NAME as MSA,

    "LOC QUOTIENT" as LQ_MSA,

    H_MEDIAN,

    If("OCC_TITLE" = 'Management Occupations', "OCC_TITLE", NULL() ) as "Management_Occupation"

FROM [lib://Employment/MSA_M2014_dl.xlsx]

(ooxml, embedded labels, table is MSA_dl);

View solution in original post

10 Replies
ecolomer
Master II
Master II

Try writting Null() in your expresion.

swuehl
Champion III
Champion III

Try

LOAD

    AREA_NAME as MSA,

    "LOC QUOTIENT" as LQ_MSA,

    H_MEDIAN,

    If("OCC_TITLE" = 'Management Occupations', "OCC_TITLE", NULL() ) as "Management_Occupation"

FROM [lib://Employment/MSA_M2014_dl.xlsx]

(ooxml, embedded labels, table is MSA_dl);

ecolomer
Master II
Master II

This is the same I said

swuehl
Champion III
Champion III

I added also single quotes around the literal 'Management Occupations'

ecolomer
Master II
Master II

Ok, I'm sorry

MarcoWedel
MVP
MVP

If(OCC_TITLE = 'Management Occupations', OCC_TITLE) as Management_Occupation


should also work.


regards


Marco

jleefjcapital
Creator II
Creator II
Author

Thank you!

jleefjcapital
Creator II
Creator II
Author

Thank  you!

jleefjcapital
Creator II
Creator II
Author

Thank you!