Dynamically filter tasks by due date

What I’m trying to do

My goal is to have a filter/checkdown/buttons on my daily page, that I can use to filter the tasks down to either current day, current week, current month, or all without needing to have all of the queries in seperate sections (see below)

Things I have tried

Currently my daily page looks somewhat like this:


Over Due

not done
due before <% tp.date.now(“YYYY-MM-DD”) %>

### Due in future

not done
(due after <% tp.date.now("YYYY-MM-DD") %> ) OR (no due date)

I have found a snippet on github: Snippet that creates filters for dataview in general but not for my tasks and I am not sure whether it is possible to fine tune it to my needs.

Does anyone know a way to achieve these filters?

I’m using this code for Overdue Tasks

not done
due before today
sort by due

and this for This week tasks (meaning from monday to sunday)

not done
due after today
due before in 1 week
sort by due

(both of course have the right code for tasks (```tasks and closing with other three backticks)
Hope to be of any help

Maybe I did not express myself correctly, all of the queries work individually without any issues.

I just do not want to have 4 sections with individual queries but ideally just one section with several filters to display the correct query.