Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
QlikWorld 2022, LIVE in Denver CO., May 16-19, 2022. REGISTER NOW TO RECEIVE EARLY BIRD PRICING
cancel
Showing results for 
Search instead for 
Did you mean: 
wanyunyang
Creator II
Creator II

Duplicates in bar chart dimension

My data has columns: ID, Date_Time (both Date and Time). I'm trying to create a bar chart, with Hours (civilian format) as dimension, count(ID) AS measure.

 

My script is like:

LOAD ID, timestamp(Date_Time, 'h TT') AS Hour...

 

But my bar chart shows duplicates in dimensions as below:

1.PNG

 

Any idea why? And how should I fix this?

 

Thanks in advance!

4 Replies
rogerpegler
Creator II
Creator II

The apparent duplicates will be due to the date part of Date_Time being different. Try:

timestamp(frac(Date_Time), 'h TT') AS Hour

wanyunyang
Creator II
Creator II
Author

Hi there, 

I gave it a go, still have duplicates.

wanyunyang
Creator II
Creator II
Author

I got this by using Time#(Time(Date_Time,'h TT')), but I have no idea why...

rogerpegler
Creator II
Creator II

Your function is using Time() to convert the underlying data into a time format for display and Time#() to convert that display value into a time. It's effectively rounding the the time component to the preceding hour.

My previous (incorrectly) suggestion assumes your time components are already rounded to the hour.