dataview using dataview custom element created by a dataview call

Searching has not helped and I am hopeful that maybe there is something I am missing

I am relatively new to obsidian and enjoying it, the goal I have had is to create on the fly word count for the daily journal I have started. I wasn’t happy with the various plugins and have managed this instead by including the following in my template where I could reduce the total words by the template and its properties while outputting a property for dataview that it should be able to read in… in this case it does not but if I put in “[estWords2::678]” then it will work for estWords2.

the code I use that I found elsewhere and adjusted for me and my needs… basically it only calculates for the specific page I am within.

LIST WITHOUT ID "[estWords::" + estWords + "]"
	WHERE file.name = this.file.name
	FLATTEN regexreplace(file.path, "/?[^\/]+$", "") as parentFolder
	FLATTEN length(file.name) as tcc
	FLATTEN length(split(file.name, "[ _\.]")) as twc
	FLATTEN round(0.95 * file.size - length(string(file.frontmatter))) as estChars
	FLATTEN round(estChars / 5.1-132+46) as estWords
	FLATTEN round(estWords / 300) as estPages
	SORT file.size DESC

(note if you want to use this, just change the -132+46 to equal zero when you open a template)

this outputs in a dataview box:

  • estWords: 678

and i think the “*” or the dataview box is the issue to be honest. so when I try to output it to a dataview table in another sheet, thinking I can gather some statistics and things on just how many adjusted words I am doing each day, etc… (yes, i am a data nerd… ) it comes out without the data / numbers., but like this:

File10 dateformat(file.mtime, “yyyy.MM.dd - HH:mm”) Last modified
2024-10-18 2024.10.18 - 15:04 * estWords +
2024-10-17 2024.10.18 - 08:42 * estWords +

you see it does not output the number but “* estWords +” … seems something in the parser gets stuck in this case., Here is the code I am using:

TABLE dateformat(file.mtime, "yyyy.MM.dd - HH:mm"), estWords
AS "Last modified" 
FROM "_personal/Daily Journals" 
WHERE estWords > 0
SORT file.ctime 
DESC LIMIT 10 

if i should use the text as I input it manually eg i type in the text “[estWords2::678]” then it will pick it up:

then the output is:

File1 dateformat(file.mtime, yyyy.MM.dd - HH:mm) Last modified
2024-10-18 2024.10.18 - 15:04 678

notice today i had 678

… Maybe using the inline JS would work (?) but it seemed a bit more complex than the dataview as I am using it now. … but if anyone knows how to convert it I would appreciate it.

So basically it seems like you’re using a LIST query to produce an inline field, which you want to use in another query. This won’t work. The second query won’t see that dynamic inline field.

You can change the first query to become a dataviewjs query and call processFrontMatter() to store the calculated value into the properties making the value become a static value (that is updated every now and then :slight_smile: )

1 Like

ahh, that was what I was afraid of, thank you for confirming!!!

I will look at converting to the inline code, but when I took a quick look at it, it seemed a bit daunting - i will now take a more serious look at it.

Thanks!

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