Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Vidit
Creator
Creator

Divide Time into time slots/ time range?

Hi,

i have the following table and i need a timeslot column.

Table:

Trans
  Number
Time
19:00
29:15
98:17
1110:22
1812:00
209:01
310:01
48:09

output Required:

Trans
  Number
TimeTime Slot
19:009:00-9:30
29:159:00-9:30
98:178:00-8:30
1110:2210:00-10:30
1812:0012:00-12:30
209:019:00-9:30
310:3110:30-11:00
48:598:30-9:00

Kindly suggest.

7 Replies
Gysbert_Wassenaar

Something like this:


Let vEpsilon  = Pow(2,-27);

LOAD

     [Trans Number],

     Time,

     Time(floor(Time + $(vEpsilon),1/48),'h:mm') & '-' & Time(ceil(Time + $(vEpsilon),1/48),'h:mm') as [Time Slot]

FROM ...


talk is cheap, supply exceeds demand
MarcoWedel

Hi,

assuming that the two last rows in your output tables include typos one solution could be:

QlikCommunity_Thread_169010_Pic1.JPG

QlikCommunity_Thread_169010_Pic2.JPG

tabTransactTimes:

LOAD @1 as [Trans Number],

    @2 as Time,

    Dual(Time(SubField(Class(@2,'00:30'),'<=',1),'hh:mm')&'-'&Time(SubField(Class(@2,'00:30'),'x <',2),'hh:mm'),Class(@2,'00:30')) as [Time Slot]

FROM [https://community.qlik.com/thread/169010] (html, codepage is 1252, no labels, table is @1, filters(Remove(Row, Pos(Top, 1))));

hope this helps

regards

Marco

MarcoWedel

Please close your thread if your question is answered.

Thanks

Regards

Marco

thirumalaivadiv
Contributor III
Contributor III

Hi MArco,

I tried similar code for the 2hrs interval for timeslot it dint seem to work.And the input field is DateTime.

Can you help me how to acheive the same.Attached is the change in interval

thirumalaivadiv
Contributor III
Contributor III

Hi MArco

 

Attach is the qvw which i tried with my file and the expectation image

 

Thanks

Thiru

thirumalaivadiv
Contributor III
Contributor III

source file attached here

thirumalaivadiv
Contributor III
Contributor III

qvw mised to attached in the previous thread