Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
vikasshana
Creator II
Creator II

IF statement in Qlik sense is not working as I expected

Hi,

I'm stuck with the if statements, below is the code which I'm using.

Example Load statement

Dim:

Load ID,

if(Column1='test1','Testing one',

if(Column1='test2' or Column1='test3','Testing two & three')) as Type1

if(Column1='test1' or Column1='test2' or Column1='test3',Column1)) as Type2

Mapping1:

Load ID, Type1 resident Dim;

Mapping2:

Load ID, Type2 resident Dim;

Fact:

Load Sales, ID_FACT

applymap('Mapping1',ID_FACT,null()) as new_type1,

applymap('Mapping2',ID_FACT,null()) as new_type2

Output:

new_type1new_type2Sales
Testing onetest1100
Testing two & threetest20
Testing two & threetest30

 

Expected Output:

new_type1new_type2Sales
Testing onetest1100
Testing two & threetest20
Testing two & threetest30
Testing two & three-200

 

Regards,

Vikas

Labels (3)
2 Replies
Taoufiq_Zarra

@vikasshana  can you share a sample data ?

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Or
MVP
MVP

Your output doesn't seem to logically match your conditions, I think. In order for the first field to be Testing two & three, you need the dimension to be either test2 or test3. But if it's either of those, then the second mapping field can't be null - it has to be either test2 or test3.

 

That said, it's hard to get a full grasp on this without the actual data you're inputting into this script (and also without the ID field from the dimension/fact table since you didn't include those in either section of your output tables).