Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
william_fu
Creator II
Creator II

"If and" statement with null handling in script

I have a flag which should trigger only when DtPrejuizo < DtReferencia, but not for rows where DtPrejuizo is null:

    If(Date(Date#([DtPrejuizo], 'YYYYMMDD')) < Date(Date#([DtReferencia], 'YYYYMMDD'))

    and Len(Trim([DtPrejuizo]))>0 , 1, 0) as FlagPrejuizo,

I'm using FlagPrejuizo={'0'} in the "Current SALDO" measure; it is working as expected for the first four rows, since DtPrejuizo > DtReferencia.

However the result is zero for the last two rows, where DtPrejuizo is null, when I want it to be the same as "SOMA SALDO"

_dterefeffe.PNG

I also tried a nested if, with the same results.

13 Replies
sunny_talwar

Can you share the complete script?

william_fu
Creator II
Creator II
Author

Sorry about the confusion, the problem was that I had the 'DtPrejuizo' field in both tables; in one of the them the nulls were actually null, while the other one displayed them as "19000101".

william_fu
Creator II
Creator II
Author

Sorry about the confusion, the problem was that I had the 'DtPrejuizo' field in both tables; in one of the them the nulls were actually null, while the other one displayed them as "19000101"

prabhu0505
Specialist
Specialist

Guess problem is with Date Interpretation function. Replicated your scenario, worked without any issues. !