Hello, I can`t create Time Series Chart. It returns error: "The "series" property must contain data in chronological order".
-data is from Named Query
-columns are labeled
-first column is timestamp (smalldatetime datatype)
-values are number values (real datatype)
Your data is arriving in reverse date order.
Show us your SQL query if you need help fixing it. Paste it as code (not a picture) and format it using the </> button.
Tip: for bulleted lists in Markdown syntax you need to start each line with dash-space, '-
'.
1 Like
This is my SQL query:
select b.readingDate as 'timestamp', a.meterReading-b.meterReading as 'usage' from dbo.gasMetersReading as a
inner join dbo.gasMetersReading as b on
a.readingDate=dateadd(HOUR,8,b.readingDate) and
DATEPART(MINUTE, b.readingDate)='00' and
(DATEPART(HOUR, b.readingDate)='6' or DATEPART(HOUR, b.readingDate)='14' or DATEPART(HOUR, b.readingDate)='22') and
b.readingDate>=:startDate and b.readingDate<=dateadd(DAY,1, :endDate) and
a.gasType like 'h3.90N_10He'
order by b.readingDate desc;
I deleted DESC keyword and it`s works. Thank you.
1 Like
Good work.
A minor thing: your line a.gasType LIKE 'h3.90N_10He' has no '%' wildcard so it's really the same as
a.gasType = 'h3.90N_10He'`. It's not doing any harm though and it might be convenient if you want to add in a wildcard in future.
I would also recommend adding a little air into your query to make it more readable and be consistent about using SQL keywords in all-caps or all-lowercase.
Reformatted query
SELECT
b.readingDate AS 'timestamp',
a.meterReading-b.meterReading AS 'usage'
FROM dbo.gasMetersReading AS a
INNER JOIN dbo.gasMetersReading AS b
ON
a.readingDate = DATEADD(HOUR, 8, b.readingDate)
AND
DATEPART(MINUTE, b.readingDate) = '00'
AND
(
DATEPART(HOUR, b.readingDate) = '6'
OR
DATEPART(HOUR, b.readingDate) = '14'
OR
DATEPART(HOUR, b.readingDate) = '22'
)
AND
b.readingDate >= :startDate
AND
b.readingDate <= DATEADD(DAY, 1, :endDate)
AND
a.gasType LIKE 'h3.90N_10He'
ORDER BY b.readingDate;
Thank you for advices, sir. Your query is much more readable. I will use your tips in future.