Dataview and List with one element

I took this question as a starting point.

And create 2 md files

Simple List

---
tags:
  - bookmarkTest
---

### Simple List

* (bookmark:: [What are microservices?](https://microservices.io))

And
Multi List

---
tags:
  - bookmarkTest
---

### Multi List

* (bookmark:: [What are microservices?](https://microservices.io))
* (bookmark:: [What are microservices?](https://microservices.io))

Also I created BookmarkTest to display all lists

` ``dataview
TABLE WITHOUT ID 
	bookmark
FROM
	#bookmarkTest
WHERE
	bookmark
` ``

So my question.
Why is bullet not displayed when there is one item in the list??

image

1 Like

Because second case is an array (a list of values) and the first case is a single value.

If you want all cases with a bullet (a list prefix) you need to convert that cases (with single values) to lists.

maybe with something like:

choice(typeof(bookmark) = "array", bookmark, list(bookmark)) AS "Bookmark"

Ok and also small question

TABLE WITHOUT ID 
	choice(typeof(bookmark) = "array", bookmark, list(bookmark)) AS "Bookmark"
	, length(Bookmark) as count
	, length(tags) as numtags
	, "#" + join(tags, ", #") as tags
FROM
	#bookmark
WHERE
	bookmark
SORT 
	file.name ASC

How I can add count of this list items?

yes of course I can do sonething like this

	choice(typeof(bookmark) = "array", bookmark, list(bookmark)) AS "Bookmark"
	, length(choice(typeof(bookmark) = "array", bookmark, list(bookmark))) as count

But it will be a double conversion

Yes, you’re right, it’ll be a repeated conversion…
But, because I still see some lack of knowledge about the metadata structure and syntax in dataview, I think I can’t advance with the suggestion of the code with the command FLATTEN to solve the repetition… (because after FLATTEN it will be necessary GROUP BY and so one).
Maybe you need to solve first your understanding about the tags: tags in content; tags in frontmatter; etc. What’s the difference in using the key field tags or file.tags (or file.etags)?
For example, you write this:

TABLE WITHOUT ID 
	choice(typeof(bookmark) = "array", bookmark, list(bookmark)) AS "Bookmark"
	, length(Bookmark) as count
	, length(tags) as numtags
	, "#" + join(tags, ", #") as tags

maybe you want to explore this:

TABLE WITHOUT ID 
	choice(typeof(bookmark) = "array", bookmark, list(bookmark)) AS "Bookmark",
	length(bookmark) as count,
	length(file.etags) as numtags,
	join(file.etags) as tags

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