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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
tmumaw
Specialist II
Specialist II

Time as a Dimension

Hi all,

I am trying to use the following as a dimension with no luck.  What am I missing? 

Thanks

time(date(Opportunity.CreatedOn,'YYYY/MM/DD hh:mm:Ss'),'hh TT') as Hour_Created

Example:

12 PM  and then counting the number of opportunities created at 12 PM.

1 Solution

Accepted Solutions
MarcoWedel

Hi Thom,

the trick is to let only the hour part of your timestamp count as a distinct value.

All formatting time functions (time, date, timestamp) do not change the numerical representation of your Opportunity.CreatedOn timestamp and therefore are not sufficient per se.

Therefore you have to round or truncate the timestamp to full hours or extract it's hour part.

Possible solutions are e.g.:

QlikCommunity_Thread_121185_Pic2.JPG.jpg

QlikCommunity_Thread_121185_Pic3.JPG.jpg

QlikCommunity_Thread_121185_Pic4.JPG.jpg

a not functioning example would be:

QlikCommunity_Thread_121185_Pic5.JPG.jpg

because this expression does not remove the differences of the minutes part of the timestamp.

hope this helps

regards

Marco

View solution in original post

15 Replies
its_anandrjs
Champion III
Champion III

The expression seems ok if you try with

Eg:-

=Time(Date(now(),'YYYY/MM/DD hh:mm:ss'),'hh TT') //Same as your expression

tmumaw
Specialist II
Specialist II
Author

The expression works perfect, but when I use Hour_Created as a dimension I get the following:

12 PM 1

12 PM 1

12 PM 1

Where is should be 12 PM 3

Clever_Anjos
Employee
Employee

You must get only time fraction

time(frac(Opportunity.CreatedOn),'hh TT') as Hour_Created

or

time(round(frac(Opportunity.CreatedOn),1/24),'hh TT') as Hour_Created if your field holds minutes too

its_anandrjs
Champion III
Champion III

Plot list box of Opportunity.CreatedOn and in expression write code

Len( time(date(Opportunity.CreatedOn,'YYYY/MM/DD hh:mm:Ss'),'hh TT') )

Check it is 5 or 7 if it is 5 then ok but 7 need to check your load script.

Not applicable

hi

try this

date(date#(Opportunity.CreatedOn,'YYYY/MM/DD hh:mm:ss'),'hh TT')

tmumaw
Specialist II
Specialist II
Author

It's 5

tmumaw
Specialist II
Specialist II
Author

Nothing in Hour_Created.....

its_anandrjs
Champion III
Champion III

Try one of this

=Time(Timestamp(Opportunity.CreatedOn,'YYYY/MM/DD hh:mm:ss'),'hh TT') as Hour_Created

Or

=Time(Date(Opportunity.CreatedOn,'YYYY/MM/DD hh:mm:ss'),'hh TT')

Or

=Date(Date#(Opportunity.CreatedOn,'YYYY/MM/DD hh:mm:ss'),'hh TT')

Not applicable

OK, PLEASE TRY ACCORDING TO THIS

=date(date#(

now()

,'MM/DD/YYYY hh:mm:ss TT'),'hh TT')