First, search the help docs and this forum. Maybe your question has been answered! The debugging steps can help, too. Still stuck? Delete this line and proceed.
What I’m trying to do
I would like this following dataviewjs table query to sort desc by the highest progress made.
I want to be able to see which series I have the most progress with. Here is the query.
let pages = dv.pages("#s/HR💟").where(p => p.seriesFinished == null && p.seriesStarted !== null) // Source dv.table( //Create the table ["Title", "Books Read", "Progress", "Up Next/Current"], //Define the columns pages.map(p => { //Map `pages` to the columns const booksInSeries = p.file.inlinks; let booksReadLinks = []; booksInSeries.forEach(b => { //Loop through all the books in a series const book = dv.page(b.path) //Process the link (since inlinks were retrieved) into a file if (book.file.tags.includes("#read✅")) { //Check if the file's tags includes... booksReadLinks.push(book.file.link) //Push the book's file link into `booksReadLinks` } }) let upnext = []; booksInSeries.forEach(b => { //Loop through all the books in a series const book = dv.page(b.path) //Process the link (since inlinks were retrieved) into a file if (book.file.tags.includes("#upnext")) { //Check if the file's tags includes... upnext.push(book.file.link) //Push the book's file link into `upnext` } }) const booksReadOverTotal = `${booksReadLinks.length}/${booksInSeries.length}` /* Progress Bar */ let progress; const value = Math.round((booksReadLinks.length / booksInSeries.length || 0) * 100); //Divide the books read by books in series, multiply by 100 and round if (value == 100) { //If the value is 100/100 (complete), give a special class to the progress bar (for stylizing); optional progress = `${value}% <progress class='complete' value='100' max='100'></progress>`; } else { progress = `${value}% <progress value='${value}' max='100'></progress>`; } return [p.file.link, booksReadOverTotal, progress, upnext] }))
Things I have tried
I have looked on the forum and discord to see if there are any other example that I could used to figure it out on my own, but I have not been successful. I am not sure where I need to add the sort command. Can anyone help?