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

Announcements
Talend Cloud AWS EU Scheduled Outage: Starting Tues 26 May 21:00 CEST with expected completion Wed 27 May 01:00 CEST
cancel
Showing results for 
Search instead for 
Did you mean: 
sachin1
Contributor III
Contributor III

Correction Required for Last 15 Days and Last 30 Days Flags in Date Filtering Logic

I want the Last30Days flag to include Order from the last 30 days up to today, starting from today (not from a fixed date like November 30), also for same Last15Days Flag.

When I select the 'Last 15 Days' flag, it shows dates starting from December 8, but I want it to show dates from December 15. Similarly, when I select the 'Last 30 Days' flag, the dates start from November 30. Please correct this issue.

The Last30Days flag will always capture Order within the last 30 days relative to today's date.

if(Date(Today(), 'YYYY-MM-DD') - Date(ORDER_DATE, 'YYYY-MM-DD') <= 7, 'Last7Days',
if(Date(Today(), 'YYYY-MM-DD') - Date(ORDER_DATE, 'YYYY-MM-DD') <= 15, 'Last15Days',
if(Date(Today(), 'YYYY-MM-DD') - Date(ORDER_DATE, 'YYYY-MM-DD') <= 30, 'Last30Days'

)
)
) as DayFlag

Labels (3)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

You can not assign two values to the same row, since the check on 7 days are true for all the previous 7 dates, none of those will be checked in the 15 days statement. Consider having 3 flags, one per check, as I've done below:

if(Date(Today(), 'YYYY-MM-DD') - Date(ORDER_DATE, 'YYYY-MM-DD') <= 7,
   'True', 'False') as [Is last 7 days] 


if(Date(Today(), 'YYYY-MM-DD') - Date(ORDER_DATE, 'YYYY-MM-DD') <= 15,
   'True', 'False') as [Is last 15 days] 

if(Date(Today(), 'YYYY-MM-DD') - Date(ORDER_DATE, 'YYYY-MM-DD') <= 30,
   'True', 'False') as [Is last 30 days] 

View solution in original post

1 Reply
Vegar
MVP
MVP

You can not assign two values to the same row, since the check on 7 days are true for all the previous 7 dates, none of those will be checked in the 15 days statement. Consider having 3 flags, one per check, as I've done below:

if(Date(Today(), 'YYYY-MM-DD') - Date(ORDER_DATE, 'YYYY-MM-DD') <= 7,
   'True', 'False') as [Is last 7 days] 


if(Date(Today(), 'YYYY-MM-DD') - Date(ORDER_DATE, 'YYYY-MM-DD') <= 15,
   'True', 'False') as [Is last 15 days] 

if(Date(Today(), 'YYYY-MM-DD') - Date(ORDER_DATE, 'YYYY-MM-DD') <= 30,
   'True', 'False') as [Is last 30 days]