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: 
TomBond77
Specialist
Specialist

nested if and sum

Hi experts

I need to sum up the two lines to one correct formula. If there are records which fulfill Flag = 'X' and Flag<>'X' the current Master Item (measure) doesn't work. Do you have a solution? Thank you!

 

if([Cap_D_W]='5' and [Flag]='X', count([Date]) * [Difference of Time] ,

if([Cap_D_W]='5' and [Flag]<>'X', networkdays ([Date], [Date])* [Cap_H_D] 

))

Labels (5)
1 Solution

Accepted Solutions
Sebastian_Dec
Creator III
Creator III

Nested if work in Qlik, 

Sebastian_Dec_1-1690383442858.png

 

After changing all the values from your equations to "1" I still get the error which means that the brackets are wrong.

Sebastian_Dec_2-1690383564944.png

 

 

 

Thanks & Regards,
Please close the thread by marking correct answer & give likes if you like the post.

View solution in original post

3 Replies
Sebastian_Dec
Creator III
Creator III

Nested if work in Qlik, 

Sebastian_Dec_1-1690383442858.png

 

After changing all the values from your equations to "1" I still get the error which means that the brackets are wrong.

Sebastian_Dec_2-1690383564944.png

 

 

 

Thanks & Regards,
Please close the thread by marking correct answer & give likes if you like the post.
daturpin
Partner - Creator II
Partner - Creator II

But how can [Flag] simultaneously be X and NOT X?

 

In any case I would clean it up as:

if([Cap_D_W]='5', if([Flag]='X'), count([Date]) * [Difference of Time] , networkdays ([Date], [Date])* [Cap_H_D]))

 

Which will evaluate to Null if [Cap_D_W] <> '5' 

If [Flag] = 'X' and somehow is also <>'X', it will evaluate to "count([Date]) * [Difference of Time]" (because it will evaulate the 'X' first)

And if [Flag] = 'Y' it will evaluate to "networkdays ([Date], [Date])* [Cap_H_D]"

 

 

 

Sebastian_Dec
Creator III
Creator III

[Flag] can't be X and NOT X in the same time.

Your equation is bad, because "if" expression takes 2-3 parameters insted 1.

Read this article: https://help.qlik.com/en-US/qlikview/May2022/Subsystems/Client/Content/QV_QlikView/Scripting/Conditi...

Define your condition what to do, what else to be. If you have two options: make a condition for the first and pass the second as "else".

 

 

Thanks & Regards,
Please close the thread by marking correct answer & give likes if you like the post.