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

Announcements
Note: You may notice some temporary visual or styling issues in the Community. Our vendor is actively investigating.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Items in days catogory


I´m trying to categorize some items sold.

I got itemnumber - productiondate and   day of sale  and would like to put these itemnumbers in a agecategory consisting of

1 - 60 days,  60 - 90 days, 90 - 120 days using the amount af days from productiondate and salesdate.

How do I go about that

Please help

6 Replies
amit_saini
Master III
Master III

Hi Soren,

This example may help you :

Fact_new:

NoConcatenate

load

    *,

    dual(if(TicketAge >=0 and TicketAge <= 7, '0-7 days',

    if(TicketAge >=8 and TicketAge <= 14, '8-14 days',

    if(TicketAge >=15 and TicketAge <= 21, '15-21 days',

    if(TicketAge >=22 and TicketAge <= 28, '22-28 days',

    if(TicketAge >=29 and TicketAge <= 60, '29-60 days',

    if(TicketAge >=61 and TicketAge <= 90, '61-90 days',

    if(TicketAge >=91 and TicketAge <= 120, '91-120 days',

    if(TicketAge >121, 'Above 121 days')))))))),

    if(TicketAge >=0 and TicketAge <= 7, 10,

    if(TicketAge >=7 and TicketAge <= 14, 20,

    if(TicketAge >=15 and TicketAge <= 21, 30,

    if(TicketAge >=22 and TicketAge <= 28, 40,

    if(TicketAge >=29 and TicketAge <= 60, 50,

    if(TicketAge >=61 and TicketAge <= 90, 60,

    if(TicketAge >=91 and TicketAge <= 120, 70,

    if(TicketAge >121, 80))))))))

    ) as TicketAgeGroup;

Thanks,

AS

Not applicable
Author

I dont think that will do it.

I got about 1.5 mill dates to deal with.

I believe its possible to do something with INTERVALMATCH or MAPPING - but not quite sure how to do it

tresesco
MVP
MVP

Have you tried class()?

Not applicable
Author

No - I´ve looked at it but cant see the solution.

Maybe I havent explained my trobles correctly.

I need to be able to categorize my ITEMS in when they are sold.

within 1 - 60 days

within 60 - 90 days  and so on.

So - I need to make a field with the ranges

1 - 60

60 - 90

90 - 120

So I can filter ex. 60 - 90 days

Hope that explains it a little more

regards

Not applicable
Author

Soeren,

I would create another table like:

NbrOfDays, DimRange

1, 1-60

2, 1-60

...

59, 1-60

60, 1-60

61, 61-90   (take care the 60 bound MUST belong to only ONE range)

62, 61-90

etc.

After, when loading your items, you do the computation as NbrOfDays to do the link with the previous table.

DimRange becomes a dimension that you can select in any listbox, related to your model the way you want (you decide yourself the intervals you wish). So the aggregations will work.

Fabrice

ashwanin
Specialist
Specialist

if(productiondate -[salesdate] <=60,'0 -60 Days' ,if(productiondate -[salesdate]<=90,'> 60 -90 Days'  ,if(productiondate -[salesdate]<=120,'> 90 -120 Days'  ))) as Category