# Time of last post/row by user

**URL:** <https://community.glideapps.com/t/time-of-last-post-row-by-user/1294>\
**Category:** Ask for Help\
**Created:** [October 20, 2019, 10:15pm UTC](https://community.glideapps.com/t/time-of-last-post-row-by-user/1294 "2019-10-20T22:15:22Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![apertur.co](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@apertur.co](https://community.glideapps.com/u/apertur.co)\
**Post date:** [October 20, 2019, 10:15pm UTC](https://community.glideapps.com/t/time-of-last-post-row-by-user/1294/1 "2019-10-20T22:15:22Z")

</div>

In my app (a social app where users create posts), I have a scorecard tab that shows various usage metrics for all the users. I’d like to include a metric indicating the time of last activity, _by user_. Ordinarily, I’d simply filter a timestamp field by user and find the max value. I cannot figure out a way to make this work with an ARRAYFORMULA. Any tips?

Here are the current formula and error message:

`=arrayformula(max(filter([timestamp array in database sheet],[username array in database sheet]=[array of names in scorecard sheet])))`

` **Error** FILTER has mismatched range sizes. Expected row count: 46. column count: 1. Actual row count: 54, column count: 1.`

The following formula gives the correct result for a **single cell** :

`=max(filter([timestamp array in database sheet],[username array in database sheet]=[single name in scorecard sheet]))`

This seems like it would be a common thing to do, so I hope there’s an easy solution that’s just in my blindspot. Apologies if the solution has been posted previously; I looked but couldn’t find it.

Thanks!

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [October 21, 2019, 3:22am UTC](https://community.glideapps.com/t/time-of-last-post-row-by-user/1294/2 "2019-10-21T03:22:06Z")

</div>

I like using a query to select a Max date, but I also haven’t been able to figure out how to do queries with an arrayformula, but you can build a new sheet with a query that selects user and max date grouped by user. You can then perform a VLOOKUP to look for that user in the new table. VLOOKUP is compatible with arrayformulas.

---

<div class="post-metadata">

**Author:** ![Ralf](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf/32/492_2.png) [@Ralf](https://community.glideapps.com/u/Ralf)\
**Post date:** [October 21, 2019, 8:36am UTC](https://community.glideapps.com/t/time-of-last-post-row-by-user/1294/3 "2019-10-21T08:36:07Z")

</div>

The Query function is an Array function.  
Try this “Select MAX(A) where …”  
A is the time stamp column.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [October 21, 2019, 12:02pm UTC](https://community.glideapps.com/t/time-of-last-post-row-by-user/1294/4 "2019-10-21T12:02:30Z")

</div>

I’ve never been able to put a query inside an array formula. Well, I can but it will only work for the first row. How do you set it up if you have 300 rows and you want to do a query using data, in the WHERE cause, from that row? I have to manually drag the formula down.

---

<div class="post-metadata">

**Author:** ![Ralf](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf/32/492_2.png) [@Ralf](https://community.glideapps.com/u/Ralf)\
**Post date:** [October 21, 2019, 12:49pm UTC](https://community.glideapps.com/t/time-of-last-post-row-by-user/1294/5 "2019-10-21T12:49:36Z")

</div>

I might have misunderstood the issue. Do you want to have multiple query answers in the same column? In my suggestion you can only get one query answer in the column where you place the query.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [October 21, 2019, 1:12pm UTC](https://community.glideapps.com/t/time-of-last-post-row-by-user/1294/6 "2019-10-21T13:12:18Z")

</div>

In my case I’m trying to run a query for each row since the WHERE will be different depending on other values in that row. Right now I have to manually place that formula in each row. I would like to use an arrayformula to autopopulate the formula into each row. That way if a new row is added, then the formula doesn’t have to be manually added. My query is designed to always return one result. I can understand there being problems if I was trying to return multiple results, but that’s not the case. I feel that arrayformula will not work with any function that has the potential to return multiple rows of data. I’m pretty sure that query, filter, and a handful of other functions are not compatible with arrayformula. That’s why I’m doing the 2 sheet method with a VLOOKUP that I described further up this thread. Scripting would be an option, but for simplicity, it would be nice to pull it off with formulas instead. I have run into daily processing limits with my scripts, so I try to avoid them when possible.

---

<div class="post-metadata">

**Author:** ![Ralf](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf/32/492_2.png) [@Ralf](https://community.glideapps.com/u/Ralf)\
**Post date:** [October 21, 2019, 2:07pm UTC](https://community.glideapps.com/t/time-of-last-post-row-by-user/1294/7 "2019-10-21T14:07:39Z")

</div>

OK I understand! Since the Query functions self returns an array you cannot apply the arrayformula on the Query.

---

<div class="post-metadata">

**Author:** ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)\
**Post date:** [October 21, 2019, 2:18pm UTC](https://community.glideapps.com/t/time-of-last-post-row-by-user/1294/8 "2019-10-21T14:18:02Z")

</div>

Are there any other methods you are aware of that might work? Definitely open to suggestions on this one.

---

<div class="post-metadata">

**Author:** ![Ralf](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf/32/492_2.png) [@Ralf](https://community.glideapps.com/u/Ralf)\
**Post date:** [October 21, 2019, 2:51pm UTC](https://community.glideapps.com/t/time-of-last-post-row-by-user/1294/9 "2019-10-21T14:51:57Z")

</div>

Maybe you can use the REPT function together with SPLIT and TRANSPOSE to repeat the formula down the column.

---

<div class="post-metadata">

**Author:** ![Ralf](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf/32/492_2.png) [@Ralf](https://community.glideapps.com/u/Ralf)\
**Post date:** [October 21, 2019, 7:17pm UTC](https://community.glideapps.com/t/time-of-last-post-row-by-user/1294/10 "2019-10-21T19:17:05Z")

</div>

@apertur.co Could this be a solution?

 ![Arrayformula](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/3/364256f722b326c767363a85231853c849e02ec5.png)

arrayformula(vlookup(D3:D5,sort({B3:B,A3:A},2,false),2,false) )

**vlookup looks up in the left column**  
{B3:B,A3:A} switches columns  
**vlookup looks up the first occurrence**  
sort({B3:B,A3:A},2,false) reverses the order

---

<div class="post-metadata">

**Author:** ![apertur.co](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@apertur.co](https://community.glideapps.com/u/apertur.co)\
**Post date:** [October 21, 2019, 8:20pm UTC](https://community.glideapps.com/t/time-of-last-post-row-by-user/1294/11 "2019-10-21T20:20:42Z")

</div>

> [@Ralf](#):
>
> arrayformula(vlookup(D3:D5,sort({B3:B,A3:A},2,false),2,false) )

Clever! Thanks!

---

<div class="post-metadata">

**Author:** ![apertur.co](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@apertur.co](https://community.glideapps.com/u/apertur.co)\
**Post date:** [October 21, 2019, 8:30pm UTC](https://community.glideapps.com/t/time-of-last-post-row-by-user/1294/12 "2019-10-21T20:30:00Z")

</div>

I was able to get this to work. Thanks!

Since my original post, I have an additional challenge/wrinkle. Each post is in one of three categories that is recorded in another column. Is there a way to find the last post by _user_ and _category_?

It would be great if `FILTER` worked for this!
