Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Priya_9
Contributor
Contributor

how to create bucket for date

Hi all,

please tell me how to create bucket for date.

i having data like this

from this i want to create bucket like

OrderDate
20-May-22
31-May-22
30-May-22
30-Apr-22
01-May-22
02-May-22
03-May-22
04-May-22
05-May-22
06-May-22
07-May-22

bucket

0-30days

30-60days

60-90days

>90days

kindly suggest me  to create bucket where in scripting or dashboard

Labels (1)
1 Solution

Accepted Solutions
Vegar
MVP
MVP

First. You need to ensure that you can interpret the date values as date. If they aren't date values then you can do this: date#(OrderDate, 'DD-MMM-YY')

Second  You need to identify your comparison date. I assume you want to compare with today's date  You can use today()

Third: To get the no of days between your OrderDate and your comparison  date use subtraction, like this:

today () - date#(OrderDate, 'DD-MMM-YY')

Fourth. Bucket your date diff. You can do this using an nested if statement or using interval match. For this example I'll use an nestled if statement like this.

IF(today () - date#(OrderDate, 'DD-MMM-YY')<=30, '0-30 days',

  • IF(today () - date#(OrderDate, 'DD-MMM-YY')<=60, '31-60 days', 

IF(today () - date#(OrderDate, 'DD-MMM-YY')<90, '61-90 days','>90 days')))

 

Hope this was helpful in order for you to bucket your data.

-Vegar

View solution in original post

2 Replies
Vegar
MVP
MVP

First. You need to ensure that you can interpret the date values as date. If they aren't date values then you can do this: date#(OrderDate, 'DD-MMM-YY')

Second  You need to identify your comparison date. I assume you want to compare with today's date  You can use today()

Third: To get the no of days between your OrderDate and your comparison  date use subtraction, like this:

today () - date#(OrderDate, 'DD-MMM-YY')

Fourth. Bucket your date diff. You can do this using an nested if statement or using interval match. For this example I'll use an nestled if statement like this.

IF(today () - date#(OrderDate, 'DD-MMM-YY')<=30, '0-30 days',

  • IF(today () - date#(OrderDate, 'DD-MMM-YY')<=60, '31-60 days', 

IF(today () - date#(OrderDate, 'DD-MMM-YY')<90, '61-90 days','>90 days')))

 

Hope this was helpful in order for you to bucket your data.

-Vegar

Priya_9
Contributor
Contributor
Author

Thank you