# Formula to populate previous number in lookup columns

**URL:** <https://connect.superhuman.com/t/formula-to-populate-previous-number-in-lookup-columns/38835>\
**Category:** Ask the Community\
**Created:** [March 31, 2023, 7:09pm UTC](https://connect.superhuman.com/t/formula-to-populate-previous-number-in-lookup-columns/38835 "2023-03-31T19:09:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohamed\_Elrefae](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/mohamed_elrefae/32/30480_2.png) [@Mohamed\_Elrefae](https://connect.superhuman.com/u/Mohamed_Elrefae)\
**Post date:** [March 31, 2023, 7:09pm UTC](https://connect.superhuman.com/t/formula-to-populate-previous-number-in-lookup-columns/38835/1 "2023-03-31T19:09:09Z")

</div>

https://coda.io/embed/Juugj5xnEm?viewMode=embed  
Every month i make invoice with details

1. first i make invoice number
2. then i make details of the invoice
3. then i make summary of the invice
4. every period i make an invoice
5. my calculation system is to make total work done till now and deduct Previous work done to get current value as shown in the doc  
in my doc ( Pay Details ) page
6. 
  - i select pay number

7. 
  - and then select Previous nunber manully  
and its not sufficent  
i want aformula to populatue previous number  
 ![previous month number](https://global.discourse-cdn.com/coda1/original/3X/d/8/d8f991a3b6862a20a3c51bb4feafad384da78f26.png)

---

<div class="post-metadata">

**Author:** ![Rickard\_Abraham](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/rickard_abraham/32/35007_2.png) [@Rickard\_Abraham](https://connect.superhuman.com/u/Rickard_Abraham)\
**Post date:** [April 1, 2023, 2:17am UTC](https://connect.superhuman.com/t/formula-to-populate-previous-number-in-lookup-columns/38835/2 "2023-04-01T02:17:10Z")

</div>

I added the formula for you!

- Filter rows to only get rows where Pay No is less than itself
- Sort this row by Pay No to get highest number first
- Return the Pay No value of the first item in this list

```auto
[Pay Details].Filter(CurrentValue.[Pay No] < thisRow.[Pay No]).Sort(false, [Pay Details].[Pay No]).First().[Pay No]

```

---

<div class="post-metadata">

**Author:** ![Mohamed\_Elrefae](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/mohamed_elrefae/32/30480_2.png) [@Mohamed\_Elrefae](https://connect.superhuman.com/u/Mohamed_Elrefae)\
**Post date:** [April 2, 2023, 6:39pm UTC](https://connect.superhuman.com/t/formula-to-populate-previous-number-in-lookup-columns/38835/3 "2023-04-02T18:39:50Z")

</div>

thank you very much  
the formula works well  
i need more help  
when i select Previous number manully i have option to add filter to the lookup value as shown

 ![previous auto 2](https://global.discourse-cdn.com/coda1/original/3X/a/e/ae1f65b7fe0a22ee52fb8b0a974ec00a76840205.png)  
 ![previous auto 3](https://global.discourse-cdn.com/coda1/original/3X/4/c/4c0934815a0792f0ecae0925759ef6166858a90d.png)

when iam using formula it populate this no and the option to add filter isnot available  
and it generate number from another project as shown

 ![previous auto 1](https://global.discourse-cdn.com/coda1/original/3X/f/d/fdf6d940754658c1254bd7debbebbc77ce7b6343.png)

can you help me to select Previous number for the same project in pay no table as shown

 ![pay no](https://global.discourse-cdn.com/coda1/original/3X/2/6/26d7197b39ca1e435fa1ec69a28325474bbca7e3.png)

i trial to modify the formula not working as shown

 ![previous auto 4](https://global.discourse-cdn.com/coda1/original/3X/d/b/db25737af091de5d7efde6c086f82353d877f09c.png)

---

<div class="post-metadata">

**Author:** ![system](https://yyz1.discourse-cdn.com/coda1/user_avatar/connect.superhuman.com/system/32/24484_2.png) [@system](https://connect.superhuman.com/u/system)\
**Post date:** [July 1, 2023, 6:40pm UTC](https://connect.superhuman.com/t/formula-to-populate-previous-number-in-lookup-columns/38835/4 "2023-07-01T18:40:32Z")

</div>

Closed on July 1, 2023, 6:40pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
