Dataview Problem Script - view last three edited file - without the first?

hello
I am working on my dashboard
and see the.md in the dashboard with this script.

Blockquote

	>last:
	```dataview
	list erstellt
	WHERE date(today) - file.mtime
	WHERE file.name != this.file.name
	SORT file.mtime desc
	LIMIT 3
	```

how can i remove the first entry?
exactly the last edit I do not want to have displayed.
i want to see only the second edit and the 3,4,5

i hope someone can help me :slight_smile:

thank you

Reversed LIMIT trickery

Here is a trick to remove the first entry:

```dataview
LIST list-field
FROM #f54644 
WHERE list-field
SORT list-field desc
LIMIT 4
SORT list-field asc
LIMIT 3
```

Given that you want N entries, and remove M entries, then reverse sort and limit to M + N entries, and then sort again, and limit to N entries. This does require you know the number of entries available, and are able to select a lower number for N to use.

Not sure how to do this if the number of entries are unknown, or possibly less than N.

Dataviewjs with sliceing

Another safer option would be to repeat the query using const result = dv.query() within dataviewjs, and then just slice of the first entries, before presenting the result.

```dataviewjs
const keepElements = 3
const skipElements = 1

const result = await dv.query(`
  LIST list-field
  FROM #f54644 
  WHERE list-field
  SORT list-field
  LIMIT ${ keepElements + skipElements }
`) // Remember to increase the limit by the number of skipped entries

if ( result.successful ) {
  const values = result.value.values.slice(skipElements)
   
  dv.list(values)
} else
  dv.paragraph("~~~~\n" + result.error + "\n~~~~")
```

Workflow to use this:

  • Copy your query into the DQL query part at the top
  • Change the two constants to match how many items to keep, and how many to skip
  • If you want, you can also do them as constants in the LIMIT ... statement, and .slice( ... ) statement.
1 Like

hi,
thanks for the help.
I think I can live well with the code :slight_smile:

my adaptation was like this

Blockquote

   	 list erstellt
   	 WHERE date(today) - file.mtime
   	 WHERE file.name != this.file.name
   	 
   	 
   	 
   	 SORT file.mtime desc
   	 LIMIT 4
   	 
   	 SORT file.mtime asc
   	 LIMIT 3

   	 SORT file.mtime desc
   	 LIMIT 3

thank you very much

:slight_smile:

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