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: 
Javery
Contributor II
Contributor II

If statements for calculating True/False based on two dates

Hello,

I would like to create a field which states True/False using the logic:

If Date1 is within the previous month AND (Date2 is Null OR not within previous month):

True

Else

False

I have been able to create two calculated fields to indicate if the dates are within the previous month but I don't believe this is the correct way to do so. See here (messy expression as date format we are working with is not standard):

If(If(monthstart(Date(Subfield("Custom field (Date)",',',1),'DD/MM/YYYY')) = addmonths(monthstart(today()),-1), 1)=1 and If(monthstart(Date(Subfield("Custom field (Completed Date)",',',1),'DD/MM/YYYY')) = addmonths(monthstart(today()),-1), 1)=0, '1')

Any help greatly appreciated, thank you.

Labels (5)
1 Reply
Or
MVP
MVP

If(InMonth(Date1,Today(),-1) and (Isnull(Date2) OR NOT InMonth(Date2,Today(),-1)),True(),False())

I'm not sure if the IsNull() part is even necessary, since null would not be in the previous month, but I included it for ease of reading.