Group by in dataview-table doesn't work

Things I have tried

See my descritption of the problem below…

here’s my attempt that I tried, but didn’t work:

> ``` dataview 
> Table
> regexreplace(Tasks.text, "\[.*$", "") AS milestone 
> WHERE file.tasks FLATTEN file.tasks AS Tasks
> WHERE contains(Tasks.text, "#milestone")
> WHERE !Tasks.completed
> SORT Tasks.due ASC
> GROUP By file.name
> ```

result:

What I’m trying to do

Hi guys,

All of my projects have an own note. Here I have a nice dataview, which shows me all of my milestone-tasks in all projects.
For the sake of clarity, I’d like to group them by their filename. In the following you see the ungrouped dataview that works nicely. Above you see my attempt to group my milestone-tasks. … I assume, I didn’t take into account the row.-operator, but I don’t understand how to use it… :confused:

> ``` dataview 
> Table
> regexreplace(Tasks.text, "\[.*$", "") AS milestone 
> WHERE file.tasks FLATTEN file.tasks AS Tasks
> WHERE contains(Tasks.text, "#milestone")
> WHERE !Tasks.completed
> SORT Tasks.due ASC
> ```

… it would help me even more, if I could implement that kind of grouping in the following task-dataview - but since the group-command does not occur in the tasks-doc, I assume grouping of tasks is not possible…:

> ```tasks
> not done
> tags include #milestone 
> path includes work 
> sort by due 
> sort by path
> ```

Thanks für help in advance!
kind regards,
Silias

Hi @SiliasOS, happy Saturday to you!

What happens if you change Tasks.text in your field definition to rows.Tasks.text?

``` dataview 
TABLE
  regexreplace(rows.Tasks.text, "\[.*$", "") AS milestone 
WHERE file.tasks 
FLATTEN file.tasks AS Tasks
WHERE contains(Tasks.text, "#milestone")
WHERE !Tasks.completed
SORT Tasks.due ASC
GROUP BY file.name
```

EDIT: Forgot the GROUP BY field. :slight_smile:

1 Like

Wowwww!!! Thanks Craig, the grouping worked in the dataview-table!!! :slight_smile:

And do you also have a solution for the grouping of the task-dataview?

Glad I could help!

I’m not as familiar with tasks, but the docs suggest it supports some kinds of grouping: Grouping | Obsidian Tasks

Perhaps you could try something like the following?

```tasks
not done
tags include #milestone 
path includes work 
sort by due 
sort by path
group by filename
```
1 Like

Thanks Craig, that worked perfectly fine!!!
Yeah, that helps a lot to keep track of my todos!!!
Have a nice weekend! :slight_smile:

1 Like

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