# Lookup to Text

**URL:** <https://community.glideapps.com/t/lookup-to-text/51966>\
**Category:** Ask for Help\
**Created:** [October 18, 2022, 2:55am UTC](https://community.glideapps.com/t/lookup-to-text/51966 "2022-10-18T02:55:04Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nisi](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nisi/32/36321_2.png) [@Nisi](https://community.glideapps.com/u/Nisi)\
**Post date:** [October 18, 2022, 2:55am UTC](https://community.glideapps.com/t/lookup-to-text/51966/1 "2022-10-18T02:55:04Z")

</div>

Hey hey 😃

Can y’all help me calculate a sum from a lookup column?

I’m trying to calculate the total sales of drinks within a single table. Not sure if this info is helpful, but here’s the background:  
A user can create a “recipe” and set the “price”, posts to the “RECIPE” table  
The sales tracking page pulls from the “RECIPE” table.  
A user can select a “recipe” which posts the recipe name and info to the “SALES” table

I have a couple ITE set up to track rolling sales data based on 1, 7, 31, and 365 days.

I would like to calculate the sales numbers and total sales $ with the same intervals (1, 7, 31, 365). So I created a relation to the table itself to link all the recipes together and then summarize the prices. Now, I don’t know how to actually calculate it.

Here’s what I created, what do y’all think?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/5/05010e31f961867f2e6ec91917008ff8c807b2a0.png)

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [October 18, 2022, 3:00am UTC](https://community.glideapps.com/t/lookup-to-text/51966/2 "2022-10-18T03:00:25Z")

</div>

wrong data structure… you will have so many problems getting your numbers… also 31 days??? months have different day numbers… 😉 years too… every 4  
how do you collect data for sales? each item separate row? or each receipt? or daily reports for each item?

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [October 18, 2022, 3:00am UTC](https://community.glideapps.com/t/lookup-to-text/51966/3 "2022-10-18T03:00:27Z")

</div>

By 1,7,31,365, do you mean all sales within the same day, same week, same month, and same year?

---

<div class="post-metadata">

**Author:** ![Nisi](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nisi/32/36321_2.png) [@Nisi](https://community.glideapps.com/u/Nisi)\
**Post date:** [October 18, 2022, 4:55pm UTC](https://community.glideapps.com/t/lookup-to-text/51966/4 "2022-10-18T16:55:38Z")

</div>

yes, exactly same day, week, month, year

---

<div class="post-metadata">

**Author:** ![Nisi](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nisi/32/36321_2.png) [@Nisi](https://community.glideapps.com/u/Nisi)\
**Post date:** [October 18, 2022, 4:58pm UTC](https://community.glideapps.com/t/lookup-to-text/51966/5 "2022-10-18T16:58:26Z")

</div>

It’s more of a counter/tally system rather than a true sales system. So when an item is ordered, it’s counted and a new row is added with the date/time. How do you recommend to improve or change the data structure?

---

<div class="post-metadata">

**Author:** ![slscustom.ru](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/slscustom.ru/32/77336_2.png) [@slscustom.ru](https://community.glideapps.com/u/slscustom.ru)\
**Post date:** [October 18, 2022, 5:09pm UTC](https://community.glideapps.com/t/lookup-to-text/51966/6 "2022-10-18T17:09:20Z")

</div>

Hm. Why you uses Lookup instead Rollup?

---

<div class="post-metadata">

**Author:** ![slscustom.ru](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/slscustom.ru/32/77336_2.png) [@slscustom.ru](https://community.glideapps.com/u/slscustom.ru)\
**Post date:** [October 18, 2022, 5:13pm UTC](https://community.glideapps.com/t/lookup-to-text/51966/7 "2022-10-18T17:13:25Z")

</div>

It is better i think you have another table with unique Drinks, so there you can summarize by Rollup throw multi relation needed columns

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [October 18, 2022, 6:31pm UTC](https://community.glideapps.com/t/lookup-to-text/51966/8 "2022-10-18T18:31:16Z")

</div>

This recent video of mine might help you:

> [@🗓️ Dynamically filter an inline list by TIMEFRAME (Parts 1 & 2)!](https://community.glideapps.com/t/dynamically-filter-an-inline-list-by-timeframe-parts-1-2/42671):
>
> wave Hey fellow Gliders! In this video, learn how to dynamically filter a list of records by timeframes (day, week, month, etc.) using a Choice component, some Math columns and a Make Array column. Also features the concept of a “Work Table” to keep your data tables lean! popcorn Enjoy! Part 1 [[Glide: Dynamically Filter your Data by TIMEFRAMES (Part 1)] ](https://www.youtube.com/watch?v=pApLeMYHFzE)Part 2 [[Glide: Dynamically Filter your Data by DATE RANGE (Part 2)] ](https://www.youtube.com/watch?v=AVSavEhdt6Y)

Instead of using the logic in the video to create filters, you’d use it to create relations. As @Uzo mentioned, it will require a bit of rework on the data side.

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [October 18, 2022, 7:08pm UTC](https://community.glideapps.com/t/lookup-to-text/51966/9 "2022-10-18T19:08:29Z")

</div>

I think you are doing the right thing in the way you collect data (without seeing it), I will assume it goes like that:

1. row ID
2. item row ID
3. timestamp
4. item name
5. item QTY
6. item price
7. item total
8. order status
9. notes/special request
10. item image

now to sort and filter by time frames (days, weeks, months) you need to add time sort columns:

1. convert timestamp to YYYYMMDD format and then convert to number, for day filtering
2. divide timestamp by 7, for weeks filtering. `(floor(now-timestamp))/7`
3. extract the month and year from the timestamp in the format YYYYMM for month filtering
4. extract just a year YYYY for year filtering

Now… I would go with the roll-up sum option… not the relations (faster and easier to deal with numbers)… once you apply the filter, simply do the 4 IF-ELSE columns to find matching filters and bring totals from the items, and use roll-up to sum these totals

---

<div class="post-metadata">

**Author:** ![Nisi](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nisi/32/36321_2.png) [@Nisi](https://community.glideapps.com/u/Nisi)\
**Post date:** [October 19, 2022, 2:25pm UTC](https://community.glideapps.com/t/lookup-to-text/51966/10 "2022-10-19T14:25:13Z")

</div>

Game changer, and as always your tutorials are 💯 . I’m updating dates to match this. Thank you!
