Dataview: How to apply function to all rows in array after using GROUP BY command

What I’m trying to do

I have a dataview table with a column where I calculate the time since a date as

date(today) - date as Since

I want to use the GROUP BY command on the table, which changes things into arrays. I’ve figured out how to make the other columns do what I want by appending rows. to the field name, but I can’t figure out how to do the same thing with the “Since” column.

Things I have tried

I only have very basic programming skills, which I assume is the reason I can’t figure this out. From searching online it seems like I need to use a forEach() method on the array but I can’t figure out how to do that properly. I looked through forums but I can’t find any other posts discussing this specific issue. Thanks in advance!

You could most likely do something like:

map(rows.date, (d) => date(today) - d) as Since

If you need access to more than one of the fields in a row you could try to do:

map(rows, (r) => date(today) - r.date) as Since

Thank you for your help! Those both work.

1 Like

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