Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
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);

1 Solution

Accepted Solutions
swuehl
MVP
MVP

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
MVP
MVP

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
MVP
MVP

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

ecolomer
Master II
Master II

Ok, I'm sorry

MarcoWedel

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!