# Time series Chart returns: "The "series" property must contain data in chronological order"

**URL:** <https://forum.inductiveautomation.com/t/time-series-chart-returns-the-series-property-must-contain-data-in-chronological-order/82464>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [November 29, 2023, 8:02am UTC](https://forum.inductiveautomation.com/t/time-series-chart-returns-the-series-property-must-contain-data-in-chronological-order/82464 "2023-11-29T08:02:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafal\_Samoraj](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@Rafal\_Samoraj](https://forum.inductiveautomation.com/u/Rafal_Samoraj)\
**Post date:** [November 29, 2023, 8:02am UTC](https://forum.inductiveautomation.com/t/time-series-chart-returns-the-series-property-must-contain-data-in-chronological-order/82464/1 "2023-11-29T08:02:59Z")

</div>

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)

 ![timeSeriesChartJPG](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/d/0d26fddc92283b9ff4471e33057cf6e5d9819942.jpeg)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 29, 2023, 9:40am UTC](https://forum.inductiveautomation.com/t/time-series-chart-returns-the-series-property-must-contain-data-in-chronological-order/82464/2 "2023-11-29T09:40:38Z")

</div>

![XY Chart dataset order](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/5/d5c680750fe7d8810d203d56744cfced0291ef5c.png)

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, '`- `'.

---

<div class="post-metadata">

**Author:** ![Rafal\_Samoraj](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@Rafal\_Samoraj](https://forum.inductiveautomation.com/u/Rafal_Samoraj)\
**Post date:** [November 30, 2023, 7:20am UTC](https://forum.inductiveautomation.com/t/time-series-chart-returns-the-series-property-must-contain-data-in-chronological-order/82464/3 "2023-11-30T07:20:53Z")

</div>

This is my SQL query:

```auto
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.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 30, 2023, 9:23am UTC](https://forum.inductiveautomation.com/t/time-series-chart-returns-the-series-property-must-contain-data-in-chronological-order/82464/4 "2023-11-30T09:23:17Z")

</div>

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**
>
> ```sql
> 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;
> 
> ```

---

<div class="post-metadata">

**Author:** ![Rafal\_Samoraj](https://avatars.discourse-cdn.com/v4/letter/r/59ef9b/32.png) [@Rafal\_Samoraj](https://forum.inductiveautomation.com/u/Rafal_Samoraj)\
**Post date:** [November 30, 2023, 1:31pm UTC](https://forum.inductiveautomation.com/t/time-series-chart-returns-the-series-property-must-contain-data-in-chronological-order/82464/5 "2023-11-30T13:31:33Z")

</div>

Thank you for advices, sir. Your query is much more readable. I will use your tips in future.
