How to create a table find data from different folders


I’m trying to create a table taking data from 2 differents folders, here below and example to clarify:

in a few words I have to folders with a common data (name), my aim is to looking the “name” in the folder 2 (red arrow), find it also in the folder 1 (green arrow) and build a table with some data from both folders (blue arrows) linked to this “name” value.

Can someone suggest me the correct instruction to do it?

there is also the possibility that the same “name” value in the folder 2 appears more times… I want to see a line in the table for each time that “name” value appears in the folder 2 (with the relative other values obviously).

thanks a lot for your support!!

What are the file names in your folder2? Are they the same as the name value? If so, this should be rather easy to do:

TABLE name, defLink.description, qty, price
FROM "folder2"
FLATTEN link("folder1/" + name) as defLink

This query lists all files from folder2 (fully qualified within the vault), and uses the name to lookup the same file in folder1 and calls this link the defLink (for definition link). Then the query can use defLink.description and get its description or dimension or whatever.

If however your filenames are not the same as name, I don’t know how to do a subquery matching on just the properties being the same. I know how to do it using dataviewjs, but not in a standard query like above. In other words, I strongly suggest that file names in folder1 are either the same as name or has a given prefix so it’s easy to construct the full file name when you’ve got the name part.

See also the thread below where they’re using a translation property which is a full link, which makes such lookup even easier at the cost of a slight more cumbersome property value. (In your case you’d need to change from name: 1001 to something similar to name: "[[1001]]" )

Hello Holroy,
the current solution is based on the file name, which serves as an index.
I believe the original request was this:
start from the list of files in the ‘folder2’, create a table where the “name” property is the index, then find the corresponding unique file in the ‘folder1’ that has the same “name” property.
Once the file in ‘folder1’ is found, proceed by adding its properties.
The result should be a list like:
Name (folder2) Quantity (Folder2) Price (Folder2) description (Folder1) Dimension (Folder1)

Folder2 Elements ------ Folder1 Elements

Name Qty Price Desc. Dim.
Ball-A 10 € 6 Oval 110
Ball-A 20 € 6 Oval 110
Ball-B 11 € 5 Round 120

@glvercellone , And how is that not what I’ve just described in my previous post? (And why have people started copying my answers, with almost identical wording? Is my wording so terrible?! )

Sorry Holroy, I didn’t mean to repeat what you have explained I think you are always effective and explain things very well. That said, David88 and I are working together on the same problem. Our problem is not to base the search in folder 1 on the name of the note as is done with the following line:

FLATTEN link(“folder1/” + name) as defLink

The desired approach would be to work on the notes in “folder 1” by searching for the corresponding “name” property.
Thanks for the support.

Best regards

As I read your request I read the “folder2” to be the order or item lists, or put another way the one with many elements, whereas “folder1” was the definition catalog with just one of every items.

This is way the query lists every element of “folder” using the FROM "folder2", whereas the FLATTEN ... folder1 is used as a reference to achieve just what you are depicting in your example table. So the search is indeed based on a search in “folder” looking up information from “folder1”. Is that not what you intended? If so, please explain the proper usage of your folders (and/or just switch the folders around :slight_smile: )

Yes, that’s correct! The only difference from what I had in mind is that in folder1, the unique files should not be named with ‘name’ (they are actually a sequential number from 1 to 1000), and that the search should be based on the ‘name’ property that is inside each individual note.

That would make this query almost impossible, at least for a standard query. It’s doable using dataviewjs, but that’s another beast.

Isn’t name meant to be a unique is anyways? So why not use it as the file name? Optionally you could prefix all of these files with something and add the name at the end.

Holroy, first of all, thank you for your suggestion; it has proven effective and allowed me to create a link between two folders. I would like to know if it’s possible to implement the use of a dual key in the file name. Let me explain further: can I use a file name that is composed of a first part, consisting of a unique sequential number (for example, ‘001’), followed by a second part that represents the name of the note (like ‘Test1’), resulting in a format like ‘001 - Test1’? In this case, is it possible to perform searches using either the sequential number or the name of the note?

Second question, If I wanted to delve deeply into the study of Dataview and Dataviewjs, where could I find materials (texts, in-depth analyses, videos, and more)?

Thank you.

As long as that other part isn’t fixed but can vary, you’re making it hard for yourself. If you insist on that naming, you should change the name field in folder2 to either be full links, like in name: "[[001 - Test1]]", or not as good name: 001 - Test1. The first would be better as I think that in recent version it would be renamed, if the note is renamed.

The point is that any searches like that which are not linked somehow, are very hard to do within a query. It’s kind of like a sub-query, which isn’t supported. If you can build the link to the new file, you’re good as my previous examples show, but if you’re “not sure” on the new file name (aka it has varying parts) then you’ve got a problem.

Regarding your second question, see my response on another thread below:

Ok, I’m reviewing the link you sent me and I must say it’s definitely helpful (thanks).

Regarding the query about the process I have in mind:

The result table exactly uses your suggestion but finds the file in folder 1 by searching the file name using only the first 3 characters for verification.

The second example show a differerent approch :

In this example, I create a table from the union of Folder 3 & Folder 1 and the index between the two is the Pn_b.

In both cases, whether Pn_A or Pn_B, the data is unique.

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