Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
wanyunyang
Creator III
Creator III

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 III
Creator III
Author

Hi there, 

I gave it a go, still have duplicates.

wanyunyang
Creator III
Creator III
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.