Display since the last data point

Trying to limit the displayed data from the last data point of one of the series. There are only some point in Bal, which are stored once every x months. Adj can be stored sporadically.

The other series P_Exp and P_Grid are stored daily. The graph shows a disconnect in the data points with a step, but this is due to Bal having a value there.

Could I limit the displayed curved from that point onwards?

If the fill(0) isn’t there, I only see the Bal data point. Without the fill(prevous), nothing is displayed

select (CBal) + (DBal) as Acct_Bal from 

(select cumulative_sum(diff)  as DBal from 
        (SELECT ("P_Exp") - ("P_Grid") + ("Adj") as diff FROM "Huawei_daily"  fill(0)) where time > now() -60d),

(select cumulative_sum(Bal) as CBal from Huawei_daily where time > now() -365d) fill(previous)

Hello @baskinginthesun2000,
Sorry I’m going to need help understanding what it is you want.
If you want to limit the displayed curve from a certain point, can you not change the time range?
I don’t exactly know what you mean by:

The other series P_Exp and P_Grid are stored daily. The graph shows a disconnect in the data points with a step, but this is due to Bal having a value there.

Could you annotate a picture to explain what you want the end result to look like?

@Anaisdg, Hi

You can see a step discontinuity in the graph (around 6/21). This is because there is a value for Bal, which there isn’t at any other point (the previous was 2 months before).

I would like to only show the data from that point forward, since the billing period starts on that day. I want to only have the data from the 21st onwards. Though the calculated values are correct, so even if it is showing a shorter period, it should still consider the entire span.

Basically, it is to only show the graph as shown, but from 6/21. This date is determined by the last stored value for Bal. So for future dates, it would start from wherever the last Bal was at. Still needs to find the cumulative sum for the last year of Bal

Thanks

P.S. If I use the following, I get dates correct, but can’t manage to get the correct values

select * from (SELECT (“P_Exp”) - (“P_Grid”) + (“Adj”) as diff FROM “Huawei_daily” where time > ‘${__to:date:YYYY-MM-18}’ -60d), (select last(Bal) from Huawei_daily) fill(previous)

@Anaisdg , hi

Let me know if my trying to clear things above helped? I don’t want any data older than the last value of Bal. In the first image above, it would only show the data after the step discontinuity (around the 6/21).

The reason is there is a rolling window that is the billing cycle, and once the date passes, I don’t need to display the older data from the previous bill

Thanks

I simply think you can’t do that, as you can’t use a timestamp derived from a query, to filter another query.

tbh I think InfluxDB is not the best candidate for this kind of interrogation, a classic SQL DB will achieve what you need easily.
Still, if you need to perform this kind of logic I suggest you put it somewhere else (ie: a program) as InfluxDB and InfluxQL can’t do what you are asking for out of the box. You might be luckier with Flux, but I’m still not sure

@Giovanni_Luisotto

Thanks, I’m looking at migrating to 2.x, hopefully as you say it might work better with flux