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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Week of 10 days

Is there any procedure to divide a month into 3 slabs i.e Slab1 (1st to 10th), 2nd (11th to 20th) and 3rd (21st to last day of the month)?

1 Solution

Accepted Solutions
jedgson
Creator
Creator

You could create a new field in your script:

If( Day(Yourdate_Field) <= 10, 'Slab1', If( Day(Yourdate_Field) <= 20, 'Slab2', 'Slab3'))

Or you could also use the above as a calculated Dimesion.

Jay

View solution in original post

5 Replies
jedgson
Creator
Creator

You could create a new field in your script:

If( Day(Yourdate_Field) <= 10, 'Slab1', If( Day(Yourdate_Field) <= 20, 'Slab2', 'Slab3'))

Or you could also use the above as a calculated Dimesion.

Jay

Not applicable
Author

Thanks Jay,

Its working fine in a dimension... how can I upload it in the script itself?

Regards,

Rahul

Not applicable
Author

Same way you can use it in the script.

 

If( Day(Yourdate_Field) <= 10, 'Slab1', If( Day(Yourdate_Field) <= 20, 'Slab2', 'Slab3'))

If you are taking data from sql then you can use it in query as

case when Day(Yourdate_Field)<=10 then 'Slab1' else

     case when Day(...)<=20 then 'Slab2' else 'Slab3' end

end

Not applicable
Author

Hi Swapnil,

I'm loading the data from a text file. Where in the script i have write it?

Regards,

Rahul

jedgson
Creator
Creator

Rahul,

You can place a load Statement above the load from the text file as follows:

YourTable:

LOAD

          *,

          If( Day(Yourdate_Field) <= 10, 'Slab1', If( Day(Yourdate_Field) <= 20, 'Slab2', 'Slab3'))

          ;

LOAD

          Field1,

          Field2,

          Yourdate_Field,

          Etc

FROM SomeFile.txt (txt, codepage is 1252, embedded labels, delimiter is ',', msq);

Jay