Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Meg_Qlik
Contributor II

Equal Sign not working in If Statement used to conditionally Color Code a Cell in a Table

I have a table where I want to color code the cells with the value of 0 in it (and only the cells that equal 0).

In the Background Color Expression of a table,  I have the following expression:  “If(([Suspense Date]-[Assigned Date] = 0), red())”.

No cells are colored – which is not what I expected.  

However if I change the expression to “If(([Suspense Date]-[Assigned Date] > 0), red())” I get all the cells colored red with a value greater than 0 (as expected).

I must not be checking for equality correctly because if I try “If(([Suspense Date]-[Assigned Date] = 6), red())” it still doesn’t work. 

1 Solution

Accepted Solutions
MayilVahanan

Hi 

Try like below

If(Floor([Suspense Date])-Floor([Assigned Date]) = 0, red())

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

View solution in original post

7 Replies
MayilVahanan

Hi 

Try like below

If(Floor([Suspense Date])-Floor([Assigned Date]) = 0, red())

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
sasikanth
Master

@Meg_Qlik , 

 your background color expression should be relevant to the expression used in Data tab. 

let us know more details about your graph. (Dimensions & expressions Used)

Meg_Qlik
Contributor II
Author

Mayil,

 

Thanks so much! Adding Floor worked.  Can you help me understand why it worked?  Why do I use Floor here but not when it's a greater than or less than?  (I'm a total newbie and trying to learn).

 

Thanks again!

Meg

MayilVahanan

HI 

Might be, ur date field has timestamp.

so its always has some decimal values if you subtract two timestamp values.

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Meg_Qlik
Contributor II
Author

Yes! I am subtracting two date fields in the format of: "7/27/2021 10:34:00 AM"

So you have to use Floor with timestamped values?  

MayilVahanan

Hi 

Floor function helps to ignore the time values & compare the date alone.

Hope it helps

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
Meg_Qlik
Contributor II
Author

Mayil,

Yes, very helpful! Thanks so much. 

Meg