# Adding time variable to graphs

**URL:** <https://community.glideapps.com/t/adding-time-variable-to-graphs/9811>\
**Category:** Feature Requests\
**Created:** [May 26, 2020, 4:50pm UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811 "2020-05-26T16:50:13Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gera\_Yeremin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gera_yeremin/32/7803_2.png) [@Gera\_Yeremin](https://community.glideapps.com/u/Gera_Yeremin)\
**Post date:** [May 26, 2020, 4:50pm UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/1 "2020-05-26T16:50:13Z")

</div>

I am not sure if this is possible yet but I want to add a chart that shows data for the last 30 days vs the lifetime of the info.

Is there a way to make the data time-sensitive.

---

<div class="post-metadata">

**Author:** ![Ryan\_Nisbet](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ryan_nisbet/32/7871_2.png) [@Ryan\_Nisbet](https://community.glideapps.com/u/Ryan_Nisbet)\
**Post date:** [May 26, 2020, 7:56pm UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/2 "2020-05-26T19:56:36Z")

</div>

I’d love this

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 26, 2020, 11:54pm UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/4 "2020-05-26T23:54:30Z")

</div>

Hi Gera,

As of now I don’t think this is doable just inside Glide, but here’s a workaround.

I have some random data like column A and B, then in column C I put this in the first cell.

```
={"Date type";ARRAYFORMULA(IF(A2:A<>"",IF(A2:A>=TODAY()-30,"Within 30 days","Not in last 30 days"),""))}

```

It would result in something like this.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/b/b4e3d340c7e18069793b974a422473114a718915.png)

Then you can make a chart with it, with the lifetime total value showed in the center.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/2/21ae8599a2170324e6bfdf60d23f93faba4273e5.png)

Hope it helps.

---

<div class="post-metadata">

**Author:** ![Gera\_Yeremin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gera_yeremin/32/7803_2.png) [@Gera\_Yeremin](https://community.glideapps.com/u/Gera_Yeremin)\
**Post date:** [May 29, 2020, 11:32pm UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/5 "2020-05-29T23:32:47Z")

</div>

> [@ThinhDinh](#):
>
> ```auto
> ={"Date type";ARRAYFORMULA(IF(A2:A<>"",IF(A2:A>=TODAY()-30,"Within 30 days","Not in last 30 days"),""))}
> 
> ```

You are the MAN! This is super helpful. For some reason, I am getting #REF! Error though. Am I stuck writing a complex formula for this or can I break it out a bit?

Here is the end game:  
Reviews Today  
Reviews Yesterday  
Reviews Over The Last 7 days  
Reviews Over The Last 14 days  
Reviews Over The Last 30 days

Reviews This Month  
Reviews Last Month  
Reviews in 2020  
Reviews in 2019

---

<div class="post-metadata">

**Author:** ![Gera\_Yeremin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gera_yeremin/32/7803_2.png) [@Gera\_Yeremin](https://community.glideapps.com/u/Gera_Yeremin)\
**Post date:** [May 30, 2020, 12:19am UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/6 "2020-05-30T00:19:10Z")

</div>

@ThinhDinh  
Update:  
I got the formula working for some reason though when I turn it into a chat it gives me some bogus numbers. It works in pie chart mode. If I wanted to add a bunch of my variables how would I edit your original formula?

By the way you are a boss and this was super helpful.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 30, 2020, 12:40am UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/7 "2020-05-30T00:40:26Z")

</div>

How many variables do you want to add? It would be complex, but it’s doable if we get the right logic.

---

<div class="post-metadata">

**Author:** ![Gera\_Yeremin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gera_yeremin/32/7803_2.png) [@Gera\_Yeremin](https://community.glideapps.com/u/Gera_Yeremin)\
**Post date:** [May 30, 2020, 1:07am UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/8 "2020-05-30T01:07:03Z")

</div>

Currently, I am looking at 9.

Here is how far I have gotten it.  
={“Date type”;ARRAYFORMULA(IF(  
E2:E\<\>"", E2:E\<\>"",IF(E2:E\>=TODAY()-30, ,IF(E2:E\>=TODAY()-7,  
“Within 7 days”,“Within 30 days”,“Not in last 30 days”,“Not in last 7 days”)  
,""))}

What is " E2:E\<\>" doing?

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 30, 2020, 1:07am UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/9 "2020-05-30T01:07:58Z")

</div>

That is part 3.3 in my writeup here.

> [@Tutorial: Arrayformula in Google Sheets, good practices & how to overcome Arrayformula restrictions with scripts](https://community.glideapps.com/t/tutorial-arrayformula-in-google-sheets-good-practices-how-to-overcome-arrayformula-restrictions-with-scripts/9727/):
>
> Hi, Today I will show you the script that can make copying formulas down work, when it does not work with arrayformula. But first, let’s have some introductions about arrayformula, for those who has not used this before in Google Sheets, some equivalents in Glide and some good practices while using it. I hope it can help you in building your Glide apps as well as applying it in your normal day job. 
> 
> > **1/ Definition**
> >
> > Arrayformula is defined as “a range, mathematical expression using one cell range …

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 30, 2020, 1:21am UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/10 "2020-05-30T01:21:36Z")

</div>

Hi Gera, based on the variables you have listed out I have made a sheet for you. I think it would be better to divided it into 4 columns:

- Recent: Yesterday & Today
- By days: Last 7, 14 and 30 days
- By month: This month & Last month
- By year: This year & last year

You can view the formulas in the header row of each column.

> **[ThinhDinh's Glide Lab](https://docs.google.com/spreadsheets/d/1sEQHpSKyHx9w2F_Xx3lm56SU1p-8eI81OYU5TYvQFvw/edit#gid=722281649)**
>
> Profile
> 
> Name,Image,Email,🔒Row ID
> Thịnh Đinh,\<a...

---

<div class="post-metadata">

**Author:** ![Erni\_D](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/erni_d/32/9023_2.png) [@Erni\_D](https://community.glideapps.com/u/Erni_D)\
**Post date:** [May 30, 2020, 1:30am UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/11 "2020-05-30T01:30:46Z")

</div>

looking around to learn some more abouth this feature

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 30, 2020, 1:32am UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/12 "2020-05-30T01:32:27Z")

</div>

Related to the use of date to filter a chart, if you’re interested.

> [@How to change the data of a chart according to the selected date?](https://community.glideapps.com/t/how-to-change-the-data-of-a-chart-according-to-the-selected-date/7789):
>
> I have information that is classified by date and I want to present the data according to it in a graph to represent the history to the selected day. How can I control that? When I put the component to select a date, doesn’t it link it to the table where the data is? Thank you very much for your support

---

<div class="post-metadata">

**Author:** ![Gera\_Yeremin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gera_yeremin/32/7803_2.png) [@Gera\_Yeremin](https://community.glideapps.com/u/Gera_Yeremin)\
**Post date:** [May 30, 2020, 1:48am UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/13 "2020-05-30T01:48:02Z")

</div>

@ThinhDinh You are a data modeling wizard! Thank you for putting the functions together for me.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 30, 2020, 1:48am UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/14 "2020-05-30T01:48:49Z")

</div>

My pleasure to help, feel free to put more questions if you need help, here or via personal message!

---

<div class="post-metadata">

**Author:** ![Gera\_Yeremin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gera_yeremin/32/7803_2.png) [@Gera\_Yeremin](https://community.glideapps.com/u/Gera_Yeremin)\
**Post date:** [May 30, 2020, 1:49am UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/15 "2020-05-30T01:49:53Z")

</div>

@ThinhDinh if you like I can show you the app I am working on in Glide it’s really cool and uses data I am gathering from another application and builds a back end around it. I would love your feedback on how I can make it even better.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 30, 2020, 1:52am UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/16 "2020-05-30T01:52:32Z")

</div>

Feel free to show it here, I would love to learn from you and others as well so don’t hesitate to do it.

---

<div class="post-metadata">

**Author:** ![Gera\_Yeremin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gera_yeremin/32/7803_2.png) [@Gera\_Yeremin](https://community.glideapps.com/u/Gera_Yeremin)\
**Post date:** [June 9, 2020, 9:10pm UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/17 "2020-06-09T21:10:57Z")

</div>

Hey! I used some of your code and it seemed to work like a charm.  
={“Recent”;ARRAYFORMULA(IF(E2:E=TODAY(),“Reviews today”,IF(E2:E=TODAY()-1,“Reviews yesterday”,"")))}

This give me the last 2 days based on a date in another field. For some reason it stopped working though. Any idea whats up? Maybe I broke it somehow.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [June 10, 2020, 12:51am UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/18 "2020-06-10T00:51:10Z")

</div>

What is it returning now?

---

<div class="post-metadata">

**Author:** ![Gera\_Yeremin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gera_yeremin/32/7803_2.png) [@Gera\_Yeremin](https://community.glideapps.com/u/Gera_Yeremin)\
**Post date:** [June 10, 2020, 1:02am UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/19 "2020-06-10T01:02:23Z")

</div>

Currently nothing. I am not sure what happened because it worked at some point.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [June 10, 2020, 1:03am UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/20 "2020-06-10T01:03:36Z")

</div>

Share with me the sheet, I will take a look to see what happens 😄

---

<div class="post-metadata">

**Author:** ![Gera\_Yeremin](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gera_yeremin/32/7803_2.png) [@Gera\_Yeremin](https://community.glideapps.com/u/Gera_Yeremin)\
**Post date:** [June 10, 2020, 1:21am UTC](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811/21 "2020-06-10T01:21:13Z")

</div>

What’s your email?

[Next page](https://community.glideapps.com/t/adding-time-variable-to-graphs/9811.md?page=2)
