Hi, I couldnt find an answer to my question though it might be pretty basic. Is there any way to obtain the sum of a column in dataview? (or an average)
Have a look in the documentation for sum(array) - Functions - Dataview
Iâve not used it myselfâŚ
Is there a way to have length with inline dql ? To display the number of inlinks for example.
here is one of my inline formulas for my weekly note with Days::
field for each daily note.
-
Weekly Sleep Duration Average calculation:
=round(sum(this.days.sleep-duration)/length(this.days), 4)
is this what you mean?
Exactly thanks !
Do you know if itâs possible to do query with inline dql ? To get the number of documents with tag â#âŚâ ?
Hi @Hydro, no I donât know how to do that, but it would be interesting to know if it is possible.
With the help of @mnvwvnm, I did however update the inline expression for my average sleep duration in my weekly note. I was having problems with null errors when either I hadnât made a daily note or hadnât entered data into the sleep duration field. The code was trying to divide by fields containing the number 0, or something like that.
Now the code filters out those fields. And it only include data from daily notes which contain an actual number in sleep-duration
. So if I havenât made a daily note for some of the days this week, or havenât entered a number, the formula will filter out and calculate the average sleep duration.
-
Weekly Sleep Duration Average calculation:
=round(sum(filter(this.days.sleep-duration, (p) => p)) / length(filter(this.days.sleep-duration, (p) => p)), 2)
In the weekly note under sleep and energy tracking in the table is choice(physical-activity, ââ, ââ) as âPhysical Activityâ, where does this info comes from? I donât see it in the daily note.
I have this large table:
However, itâs not showing all the entries, only about 2/3 of the ones I expect.
I have this list to keep track of which ones are there and which are not:
- [ ] Antstorm
- [ ] Applestem
- [ ] Ashflower
- [x] Barkpaw.
- [x] Birch.
- [ ] Blackjack
- [ ] Blackwing
- [x] Blossomstar
- [x] Cedarpelt
- [ ] Cherryflame
- [x] Cinderkit
- [x] Cinders
- [ ] Cloudheart.
- [x] Dawnstrike
- [ ] Fallenblaze
- [ ] Firewhisker
- [x] Fishkit.
- [ ] Flamepool
- [x] Flowerpaw
- [x] Foxwhisker
- [x] Goldenpaw
- [x] Greyfrost
- [x] Hatchbelly
- [x] Hazelkit
- [x] Holly
- [ ] Kestrelsky
- [ ] Lakespring
- [x] Leafkit
- [x] Leopardtail
- [x] Lionfrost
- [x] Littlepaw
- [ ] Logpelt
- [x] Marshpelt
- [x] Mottlespots
- [x] Mouseclaw
- [x] Mouseslip
- [x] Muffin
- [ ] Nightpaw
- [ ] Oakkit
- [x] Orchid
- [ ] Petalkit
- [x] Petalwhisker
- [ ] Plumbird
- [ ] Rainstar
- [ ] Ravenpaw
- [ ] Ripplewater
- [x] River.
- [x] Robin
- [x] Rosepaw
- [x] Rowaneye
- [ ] Sandpaw
- [ ] Shadow.
- [ ] Shimmerpaw
- [x] Shrewstar
- [x] Silverkit.
- [x] Silvernose
- [x] Snakepaw
- [x] Specklepaw
- [ ] Spiderflower
- [x] Splash
- [x] Spottednose
- [x] Stormkit
- [x] Sunstar
- [x] Tallhawk
- [ ] Tansydapple
- [x] Vixenlight
It was generated using the exact same code as for the table, only omitting the table jargon. I just copied it from the generated list, then converted it to a checklist and checked the ones visible. It seems there is no order to them being removed, though there might be a correlation between the removed notes and them linking to not yet created notes. But itâs not complete nor exclusive, so I donât believe theyâre related.
Iâm completely lost on this. Does anyone have any insight?
Not sure if you have been experiencing the same issue on your end, but the =[[<% tp.date.weekday("YYYY-MM-DD", -1, tp.file.title, "YYYY-MM-DD") %>]].to-improve
and likes were not functioning as expected on my end. I replaced the code with =[[<% moment(tp.file.title, "YYYY-MM-DD").subtract(1, 'days').format("YYYY-MM-DD") %>]].to-improve
and now all works swimmingly.
Hi @Wan,
Yes, youâre right, it should have been tp.date.now, as in =[[<% tp.date.now("YYYY-MM-DD", -1, tp.file.title, "YYYY-MM-DD") %>]].to-improve
but I have updated the templates on my GitHub the âtemporal fieldsâ to include the âsiblingâ time period, so Yesterday, or Last week/month for the weekly/monthly notes.
Hi @Saorsa, just paste - Physical Activity::
somewhere in your daily periodic note template.
You could either enter a boolean true / false, or just gibberish⌠or maybe you want to track some specifics â5 km run / 30 min swim / bushwalk with friendâ.
You could then make a separate table in the weekly review to look at that detail.
dataview
TABLE WITHOUT ID file.link as Date, physical-activity as "Physical Activity"
FROM outgoing([[#]])
where physical-activity
where week = this.file.link
^It works perfectly fine, but I donât really like the last line of the code above because it makes it a little bit more fragile. It relies on an outgoing condition and an incoming condition. I would rather if the last where
was the equivaent of the inline expression =this.days.physical-activity
. Iâll update when I know how to fix this.
- Edit - Improved table using flatten, which allows us to filter to only the outgoing links from the âdaysâ field in the weekly note. This code would break if a non-link string was in the âdaysâ field.
TABLE WITHOUT ID days as Date, days.physical-activity AS "Physical Activity"
WHERE file.path = this.file.path
FLATTEN days
SORT days
WHERE days.physical-activity != null
If I can properly understand flatten, I think it will bring me some other useful tricks in the future!
Thank you!!
Hi,
I wanted to have an overview of my current projects and their progress.
So I have notes representing projects which I tag with #current_project in the front matter:
---
tags: #current_project
---
Then I list them with Dataview, printing a filled circle for each completed task and a hollow circle for each incomplete task:
dataview
LIST replace(replace(replace(string(map(file.tasks.completed, (t) => t = true)), "true", "â"), "false", "â"), ", ", "") FROM #current_project
Here is an example:
Simple and useful, I think .
(Can undoubtedly be implemented more simply with JS, but Iâm not there yet.)
Hi @PorcoRosso I like this a lot. You can simplify your statement by doing the following:
LIST
join(choice(file.tasks.completed, "â", "â"), "")
FROM #current_project
No need for Javacript, and itâs a little bit easier to read I think.
Cool @dugdun , thatâs very elegant. Will use that instead .
Hello! thank you both for this idea and showcase, itâs a very interesting concept and very intuitive to implement.
I was wondering, is there a way to increase the resultant size of âââ, âââ that @dugdun is using in his dataview?
Hi @stfrigerioj remember that the dots are just regular characters being displayed. If you want, you can use inline styles to change the size of those. Something like the following would make them 1.5 times bigger than they normally would:
LIST
join(choice(
file.tasks.completed,
"<span style='font-size:150%;'>â</span>",
"<span style='font-size:150%;'>â</span>"
), "")
FROM #projecta
You can use any type of CSS styling that you would like.
Wow this is awesome! As a newbie with css, these insight are priceless. Thank you so much for your help
Part showcase, part question: I am trying to create something like the Tag pane core plugin but inline and filtered for creating a dynamic MOC index of tags meeting a regex criteria.
Here is a tag index dataview code that I found here (thanks @mnvwvnm !) that I sparsely modified to list in alphabetical order.
TABLE WITHOUT ID (tag + "(" + length(rows.file.link) + ")")
AS Tags, join(rows.file.link, ", ") AS Files FROM ""
WHERE file.tags
FLATTEN file.tags AS tag
GROUP BY tag
SORT rows.tag ASC
Q: How do I modify this to filter by the #tool
tag and subtags? (Using WHERE contains(file.tag, âtoolâ)
or similar doesnât work because it also grabs all of the other tags referenced in that file.
If I understand correctly⌠try this:
```dataview
TABLE WITHOUT ID (tag + "(" + length(rows.file.link) + ")") AS Tags, join(rows.file.link, ", ") AS Files
WHERE file.tags
FLATTEN file.tags AS tag
WHERE contains(tag, "tool")
GROUP BY tag
SORT rows.tag ASC
```