Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
greend21
Creator III
Creator III

Help With If/And Statement

Hi,

I'm not very familiar with writing if statements. I have fields A, B, and C. I would like field C to be yellow(vColorDBWarn) if field A is greater than 5 days old and if field B contains a value(which would be a date in this case).

In another area I only wanted field C highlighted if field A was greater than 5 days old and successfully wrote:

=if(Today()-[Field A]>=5,vColorDBWarn)

I would appreciate any help in changing that statement to add the condition of field B containing a value.

Thanks!

Dan

1 Solution

Accepted Solutions
greend21
Creator III
Creator III
Author

I tried your initial formula and two variations

Neither of these worked:

=If(Today()-[CapAdjPaid Dt]>=5 and (Len(Trim([CapAdjCeded Inv Dt])>0 or [CapAdjCeded Inv Dt]<>0)),ColorDBWarn)

=If(Today()-[CapAdjPaid Dt]>=5 and (Len(Trim([CapAdjCeded Inv Dt])<>0)),ColorDBWarn)

This did work:

=If(Today()-[CapAdjPaid Dt]>=5 and (Len(Trim([CapAdjCeded Inv Dt])>0)),ColorDBWarn)

Thank you for the help!

View solution in original post

6 Replies
sunny_talwar

May be this

If(Today() - FieldA >= 5 and (Len(Trim(FieldB)) > 0 or FieldB <> 0), vColorDBWarn)

greend21
Creator III
Creator III
Author

I tried your initial formula and two variations

Neither of these worked:

=If(Today()-[CapAdjPaid Dt]>=5 and (Len(Trim([CapAdjCeded Inv Dt])>0 or [CapAdjCeded Inv Dt]<>0)),ColorDBWarn)

=If(Today()-[CapAdjPaid Dt]>=5 and (Len(Trim([CapAdjCeded Inv Dt])<>0)),ColorDBWarn)

This did work:

=If(Today()-[CapAdjPaid Dt]>=5 and (Len(Trim([CapAdjCeded Inv Dt])>0)),ColorDBWarn)

Thank you for the help!

sunny_talwar

This would have worked had you not misplaced your parenthesis

=If(Today()-[CapAdjPaid Dt]>=5 and (Len(Trim([CapAdjCeded Inv Dt]))>0 or [CapAdjCeded Inv Dt]<>0)),ColorDBWarn)

Red is not needed and green was needed

sunny_talwar

But I wonder how this worked.... because this still have parenthesis issue....

=If(Today()-[CapAdjPaid Dt]>=5 and (Len(Trim([CapAdjCeded Inv Dt])>0)),ColorDBWarn)

greend21
Creator III
Creator III
Author

It looks like they all match up in this case.
=
If(Today()-[CapAdjPaid Dt]>=5 and (Len(Trim([CapAdjCeded Inv Dt])>0)),ColorDBWarn)

sunny_talwar

It should be more like this

=If(Today()-[CapAdjPaid Dt]>=5 and Len(Trim([CapAdjCeded Inv Dt]))>0,ColorDBWarn)