Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
QlikSenseUser2
Contributor III
Contributor III

Background Color expression by date

I'm trying to set a Background Color expression by date. I want it to show green if within a year of the Aggr(max(LAST_INSPECTION_DATE),TRAILER)  or Red if greater than a year of the Aggr(max(LAST_INSPECTION_DATE),TRAILER).

I have 

IF(Year(Aggr(max(LAST_INSPECTION_DATE),TRAILER)) > AddYears(Aggr(max(LAST_INSPECTION_DATE),TRAILER),1), LightRed(),Green())

And I get this all green

 

QlikSenseUser2_0-1626311548631.png

 

1 Solution

Accepted Solutions
Kushal_Chawda

@QlikSenseUser2  try below. Make sure that you are using below same expression on correct column. If this still did not work share the sample qvf file

=if(LAST_INSPECTION_DATE > addyears(Today(),-1) and LAST_INSPECTION_DATE <= Today(), Green(),Red())

 

View solution in original post

17 Replies
avinashelite

are you looking for the moving 1 year date or the current year to date ?

QlikSenseUser2
Contributor III
Contributor III
Author

Moving 1-year date. I would like for it to go by the  Last Inspection Date.

Anil_Babu_Samineni

You can try something this?

IF(Year(LAST_INSPECTION_DATE) = (Year(LAST_INSPECTION_DATE)+1), LightRed(),Green())

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
QlikSenseUser2
Contributor III
Contributor III
Author

It's still showing all green 

Kushal_Chawda

@QlikSenseUser2  so let's say last_inspection_date is "17-Jul-2021", so which dates should be green and which one should red? You can specify ranges to be clear

QlikSenseUser2
Contributor III
Contributor III
Author

17-Jul-2020 and before should be Red everything else Green

Kushal_Chawda

@QlikSenseUser2  then below should work

= if( LAST_INSPECTION_DATE > addyears(max(total LAST_INSPECTION_DATE),-1), Green(),red())

QlikSenseUser2
Contributor III
Contributor III
Author

It's now showing all Red

Kushal_Chawda

@QlikSenseUser2  Not sure but it's working fine for me. see the below. "15-Jul-2021" is latest date. Make sure that your LAST_INSPECTION_DATE is in proper Date format. To check that use max(LAST_INSPECTION_DATE) in KPI object, if it returns value then it's fine else there is format issue. In that case you need to first convert that field to proper date format

Kushal_Chawda_0-1626361948539.png