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: 
jagannalla
Partner - Specialist III
Partner - Specialist III

Hour field is not able to concatenate

Hello,

I've a table with script as shown below

Table1:

Load *,

     Time(Frac(Floor(DTField,1/24)),'hh') as Hour

From Table1;

FOR i=0 to 23

Concatenate(Table)

LOAD Time(MakeTime($(i)),'hh') as Hour AutoGenerate(1)

;

NEXT

- When i'm trying to concatenate the for loop with above table. It generates two values for the field Hour. i.e. 00,01,07,07,10,11,13,13

How can i overcome this?

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Not sure what you want to achieve and what you get. Are you saying you don't get any Hour values 02, 03, 04 ,05, 06, etc., despite the FOR LOOP running over all hours?

I wouldn't think it's a bug if you get duplicate value for Hours, since you are first loading some hours from a table, then concatenating each single hour (for which you don't need a FOR LOOP, you can also use autogenerate 24 and recno() function).

Creating your Hour in the first table using Frac(floor(FIELD,1/24)) seems soemwhat problematic to me, if you want a possible match with values created by Maketime(). Consider using maketime(hour(FIELD)) instead in your first load.

Hope this helps,

Stefan

View solution in original post

8 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

The first part of the load is making hours that are not exact hours as it does not remove the minute/second part of the time. The Hour keyword formats this to look the same, but does not change the underlying value.

Try this:  Time(Int(Frac(DTField) * 24) / 24, 'hh')

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
jagannalla
Partner - Specialist III
Partner - Specialist III
Author

Ok leave this.. What i want is, Through this script Time(Frac(Floor(Pallet_DT,1/24)),'hh') as Hour. I can able to get the hours from my timestamp filed. But not all 24 hours values b'coz there is no values for all hours. I can see all the hours which are existing in the timestamp. But user needs to see entire 24 hours values. Right now it shows me

00,01,07,23.

But i need the full 24 hours in same field i.e. 00,01,02,03,04,05,.......21,22,23. So that user can choose his own hours.

swuehl
MVP
MVP

Not sure what you want to achieve and what you get. Are you saying you don't get any Hour values 02, 03, 04 ,05, 06, etc., despite the FOR LOOP running over all hours?

I wouldn't think it's a bug if you get duplicate value for Hours, since you are first loading some hours from a table, then concatenating each single hour (for which you don't need a FOR LOOP, you can also use autogenerate 24 and recno() function).

Creating your Hour in the first table using Frac(floor(FIELD,1/24)) seems soemwhat problematic to me, if you want a possible match with values created by Maketime(). Consider using maketime(hour(FIELD)) instead in your first load.

Hope this helps,

Stefan

jagannalla
Partner - Specialist III
Partner - Specialist III
Author

Hi,

If i use that script it shows me red error lines in the script. What i need to do?

jagannalla
Partner - Specialist III
Partner - Specialist III
Author

Swuehl,

Please check the attached file. I don't need duplicate values.

jagannalla
Partner - Specialist III
Partner - Specialist III
Author

Time(maketime(hour(Pallet_DT)),'hh') as Hour

script works perfectly.

swuehl
MVP
MVP

Good to hear... or maybe just hour(Pallet_DT) as Hour (could also be formatted with two digits)?

jagannalla
Partner - Specialist III
Partner - Specialist III
Author

No Swuehl, just hour(Pallet_DT) doesn't work b'coz different dates has same hours. If i use this code i didn't get unique hours. I don't want want duplicate values.