First of all, I’m a new Obsidian user and I have to say this is awesome! I’ve never used anything similar to Obsidian but I’ve been looking for something like this for years, and I finally found it!
What I’m trying to do
So, I’m using Dataview and my goal is to make a counter of some characteristics I want to collect. Each note on the folder follows the same template.
For example:
“Type:: Project”
This “Type” line appears in all of my notes and it has 2 possible values, one of them is Project. The goal is to count the number of times each one of the values appears.
What’s my problem here?
My problem here is that the value is, in fact, another note.
So, basically, instead of “Type:: Project”, I actually have “Type:: [[Project]]”, and this is difficulting my life.
Things I have tried
First of all, I managed to make a counter of these to work when the value in front of the Type is a simple word. I use this code:
let countProject = 0;
// Consults data using Dataview API
for (let page of dv.pages('"Teste Mestrado Folder/Outras Teses"')) {
if (page["Type"] === "Project") {
countProject++;
} else if (page["Type"] === "Tese") {
countTese++;
}
}
// Exhibits results
dv.paragraph(`Type:`);
dv.paragraph(`Project = ${countProject}`);
dv.paragraph(`Tese = ${countTese}`);
But I wasn’t able to find the way to extract the text when it is a link.
My first reaction was simply to put the “[[” and the “]]” in the beginning and in the end of the word, respectively, but it didn’t work.
Then I searched for the AI help and it was suggested to use the replace function (basically, replace “[[” and “]]” for “” but it didn’t work too.
I searched for the Obsidian forum and I found this:
His problem is the same as mine. However, it doesn’t like it was solved. Still, I tried the .path function and I haven’t got good results.
Can you help please?
Thanks in advance,
Pedro