# Is there an easy way to sort by week number?

**URL:** <https://community.glideapps.com/t/is-there-an-easy-way-to-sort-by-week-number/66778>\
**Category:** Ask for Help\
**Created:** [October 5, 2023, 8:50am UTC](https://community.glideapps.com/t/is-there-an-easy-way-to-sort-by-week-number/66778 "2023-10-05T08:50:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![erwblo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/erwblo/32/75_2.png) [@erwblo](https://community.glideapps.com/u/erwblo)\
**Post date:** [October 5, 2023, 8:50am UTC](https://community.glideapps.com/t/is-there-an-easy-way-to-sort-by-week-number/66778/1 "2023-10-05T08:50:42Z")

</div>

What I would like:

- Add sales with date
- Automatically ad corresponding week number
- So I can sort and compare on week by week basis  
I don’t assume it will be easy, but is there a way for starters?

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [October 5, 2023, 10:25am UTC](https://community.glideapps.com/t/is-there-an-easy-way-to-sort-by-week-number/66778/2 "2023-10-05T10:25:46Z")

</div>

You can start by using a Math column to determine the Week Number from the Date, and take it from there.

```auto
Weeknum(Date)

```

---

<div class="post-metadata">

**Author:** ![erwblo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/erwblo/32/75_2.png) [@erwblo](https://community.glideapps.com/u/erwblo)\
**Post date:** [October 5, 2023, 10:27am UTC](https://community.glideapps.com/t/is-there-an-easy-way-to-sort-by-week-number/66778/3 "2023-10-05T10:27:40Z")

</div>

Ah ok! That helps!

---

<div class="post-metadata">

**Author:** ![MatthewS](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/matthews/32/40533_2.png) [@MatthewS](https://community.glideapps.com/u/MatthewS)\
**Post date:** [October 5, 2023, 11:52am UTC](https://community.glideapps.com/t/is-there-an-easy-way-to-sort-by-week-number/66778/4 "2023-10-05T11:52:03Z")

</div>

I just did this yesterday, and didn’t know of @Darren_Murphy’s Weeknum function, but managed to get dated Entries sorted into weeks (and also months) for viewing reports of these Entries.

In a helper table set columns for:

- Row index… just a manually entered incrementing number
- Start range, math column: now - WEEKDAY(now) +1 -(row-1)\*7
- End range, math column: now - WEEKDAY(now) -(row-2)\*7
- Query Entires by
  - date on or after start range, and
  - date on or before end range

 ![Screenshot 2023-10-05 at 7.41.09 AM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/8/f800221245018a8288f04fe80d167521edd5ad8a.jpeg)

I also have custom filters to choose these weekly ranges, or monthly ranges, and also by a parent category.

---

<div class="post-metadata">

**Author:** ![erwblo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/erwblo/32/75_2.png) [@erwblo](https://community.glideapps.com/u/erwblo)\
**Post date:** [October 5, 2023, 12:05pm UTC](https://community.glideapps.com/t/is-there-an-easy-way-to-sort-by-week-number/66778/5 "2023-10-05T12:05:38Z")

</div>

Thanks! I don’t know if I would have managed that.  
But @Darren_Murphy 's track did the trick.

---

<div class="post-metadata">

**Author:** ![erwblo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/erwblo/32/75_2.png) [@erwblo](https://community.glideapps.com/u/erwblo)\
**Post date:** [October 5, 2023, 4:43pm UTC](https://community.glideapps.com/t/is-there-an-easy-way-to-sort-by-week-number/66778/6 "2023-10-05T16:43:48Z")

</div>

Darren, this is great and easy, thanks.  
Can I ask you one more thing?  
Say if I wanted to see differences between this week and last week and the week before that so I could make a hit list, could you give me a beginning where and how to start?  
Never mind of course if you’re busy!

---

<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:** [October 6, 2023, 12:29am UTC](https://community.glideapps.com/t/is-there-an-easy-way-to-sort-by-week-number/66778/7 "2023-10-06T00:29:32Z")

</div>

I think you can approach it like this:

- Create a math column to calculate the current weeknum + year number:

YEAR(N)\*10^2+WEEKNUM(N)

- Create a math column to calculate last week’s weeknum + year number:

YEAR(N-7)\*10^2+WEEKNUM(N-7)

With N being the date in question.

Then, you can create a relation + lookup: Relate last week’s math column to current week’s math column, then lookup the sales from last week.

Finally, calculate the difference.

---

<div class="post-metadata">

**Author:** ![erwblo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/erwblo/32/75_2.png) [@erwblo](https://community.glideapps.com/u/erwblo)\
**Post date:** [October 6, 2023, 7:24am UTC](https://community.glideapps.com/t/is-there-an-easy-way-to-sort-by-week-number/66778/8 "2023-10-06T07:24:13Z")

</div>

Thank so much, I am going to try this!
