hi everyone, i have a question about using dataview and mapping or “concatenating”
What I’m trying to do
first of all sorry if this is a stupid question. i searched all over as much as i could and found no solution. i wonder if what i am aiming for is even possible, or if i’d need dataview js…?
so to explain, here is an example set-up:
i have in my note:
field1 :: 2
field2 :: 1
field1 :: 4
field2 :: 3
of course, the numbers 1,2,3,4 in this example stand for a string (value)
in reality 1 may be “x y z”, 2 may be “a b c”, etc.
when we use the command:
TABLE WITHOUT ID
field2, field1
WHERE file = this.file
we will get two columns:
field 2:
1
3
field 1:
2
4
my question is:
how do i map the two columns to each other, as if concatenating in excel, so that i get:
and of course the moment i posted this, my brain decides to hit me with a workaround, haha.
do reply if you are interested to see it, even if it may be sloppy “code”. (kind of ashamed but well, i’m very new to obsidian & dataview…)
but also, if someone can share their solution which may be better, i’d be very happy and thankful for your help.
You’re kind of building a very brittle datastructure doing it this way. If you are unlucky/unfocused/… you might at one point misspell or leave out either of the fields, and your entire structure is skewed and not making any sense. Imagine doing “field1” or “fieId1” or similar (that is in monospace "field1" or "fieId1"). Such an error could mean your entire data set is bodged, and unreadable.
If you on the other hand used list context, and place both of these fields on the same bullet point they would be connected, and you would also have an easier way of displaying/showing connected values together.
Connecting your brittle structure as is, isn’t very easy. One way of doing so is to create a range, and selecting the corresponding element from both fields at the same time. Another way could be to wait for Dataview to implement zip() (which does this operation (inspired from the Python variant of the same function)). The latter might be implemented in the near future by yours truly, but then again I’m quite busy at the moment.
thank you for your reply, my example setup was actually just that, an example, so don’t worry, i don’t actually have notes where the fields are just “field1” “field2” etc haha