Dataview Combine Multiple Values Into Single Column

I have two separate entries in a file
10:55 - maintain:: Some Task
11:17 - maintain2:: Some Other Task

Is it possible to have both show in the same column?
I tried this but it does not work

table dateformat(date, "cccc") as Day, ((maintain as Task) or (maintain2 as Task))
FROM #Journal and -"zzzTemplates" 
WHERE (date(today) + dur(1day)) - file.cday <= dur(7 days)
and ((maintain) or (maintain2))
sort desc

Hi, again.

Two things:

  1. If you use literally this format, you don’t have any field:

If you want to use the full-inline format (key:: value) you can’t add text before your field. You can use this format:

maintain:: Some Task
- maintain2:: Some Other Task

If you want to keep all the content in the same line, then you need to use the inline field in the format [key:: value] or (key:: value) (the difference in the brackets is related to the render of the field - you need to enable the inline field highlighting in settings > dataview - round brackets hides the key):

10:55 - (maintain:: Some Task)
11:17 - (maintain2:: Some Other Task)
  1. About the query, I have some difficult to understand your goal… If you want a list of “maintain” values in each note, why you give two different key names? Why you don’t use the follow format (multiple values for same key)?
10:55 - (maintain:: Some Task)
11:17 - (maintain:: Some Other Task)

If you want to join two fields in same column you can work with list(maintain, maintain2) AS "Tasks"… but you’ll have issues when one of the values is empty; or if you want the output as a string (and not a list), you can use default(maintain, "") + ", " + default(maintain2, "") AS Tasks; or …

1 Like

Thanks, The list works for me.

Note: it does work for me with text before the field e.g. like this on same line
12:19 - (bmt) maintain2:: Brush my teeth

I’m trying different keys because I want to see if I can create some reports for only some of the “maintain” items
But on one report, I would like them all in the same column.

1 Like

Wait!!! This format works with you?! Are you using any special plugin that also use metadata fields?
If you use this simple js inline query (you need to enable js queries in settings > dataview):


these fields are listed?

(note: with this inline query in a specific note you can see all “queryable” metadata in that note… and the structure of the metadata)

I don’t THINK I am am using any special plugin

(But I have played with many different ones)
I had these two enabled in the dataview settings but it still works with them disabled

Thanks for the reply.
These dataview settings don’t have influence in the metadada. I mentioned them only to you use the inline query $=dv.span(dv.current()). It’s a useful query to check all metadata in the current file and to learn how the metadata is structured. (don’t expect a rendering of inline queries in Live Preview, only in reading view - I’m using the “old” editor legacy, so I don’t use LP)
Well, returning to the inline field, this is very strange. But if works for you… take advantage of it :slight_smile:

It seems to only work inline because I have my letter code in parenthesis before the key

12:19 - (bmt) maintain2:: Brush my teeth - Works
12:19 - maintain2:: Brush my teeth - Does not work
12:19 - ) maintain2:: Brush my teeth - Works

I am also using the legacy editor

Also works if you put it in brackets

16:49 - [maintain:: Put away dry laundry]

oh! you’re right!
I tested now… It’s even stranger…
If you run the inline query you get this:

As you can see, the other two works but ignoring “:19” and ignoring what have brackets…

yes, that is supposed to work: also with round brackets (in this case “maintain” hides when rendered)

The documentation here is suggesting brackets, so I may just go that way to be safe

As I said in my first post, that is the best option for your case (the use of brackets).
In the other cases dataview read the field key in this way:

  • 12:19 - maintain2:: Brush my teeth - in this case dv try to read “12:19 - maintain2” as the name of the field. but the use of “:” - a prohibited symbol - creates an issue and the field name is replaced by “19 - maintain2”;
  • in 12:19 - (bmt) maintain2:: Brush my teeth and 12:19 - ) maintain2:: Brush my teeth dv try to read all expression before “::” as the key name, but the combined use of numbers, “:” and “(” or “)” seems to be ignored and retains the key only as “maintain2”.
1 Like

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