"Group by" Woes

You’re still hitting the same wall of page vs item scope. The FROM is related to the note, aka page scope, so if the entire file has both, it’s happy. Then on the next line (with FLATTEN) you split the page scope, and start using the item scope with stuff like WHERE item.quote and SORT item.source ASC.

In order to match each item against tags, you’ll need to extend the WHERE query with matches against its tags, so something like the following (replace the whole WHERE statement):

WHERE item.quote
  AND contains(item.tags, "#pin/class/quote")
  AND contains(item.tags, "#pin/topic/politics/american/gop/anti-government")

thanks so much, I think i bit off a bit more than I could handle, but I’m so close! :slight_smile:

I did what you asked, but got a parsing error. In case I mistyped something, here is my full code:

Table 
  item.quote as Text,
  item.source as Source,
  item.topic as Topic
FROM #pin/class/quote AND #pin/topic/politics/american/gop/anti-government  
flatten file.lists as item
WHERE item.quote
  AND contains(item.tags, #pin/class/quote)
  AND contains(item.tags, #pin/topic/politics/american/gop/anti-government)
Sort item.source ASC

I tried it with and w/o the FROM as I wasn’t sure.


I have another issue as well. In another test I did with this code:

TABLE WITHOUT ID link(file.link, Title) AS "Title", Aliases, Born, Death, Birthplace, Note
FROM #note/type/person AND -"Templates"
SORT file.link ASC

The results included pages that had sub-tags. E.g. #note/type/person/deceased

I do not want results for #note/type/person/deceased but only #note/type/person

Is that not possible?

Reread my last reply… I corrected it… :smiley:

You can keep the FROM as it limits the overall set a little, making the rest of the query a little bit easier.

And for that part you need either need to do an exact check against the full tag, or remove those not wanted.

To test against the full tag, you could either use something like WHERE econtains(file.etags, "#note/type/person") (and yes, it needs to be: econtains and file.etags), or to remove those not wanted change the FROM into something like FROM #note/type/person AND -#note/type/person/deceased

Why econtains? See Functions - Dataview. Why file.etags? Try outputting them both in your table query, and see the difference.

BRILLIANT!! thanks so much! This has a real journey… I dont understand fully and it’s not the most frictionless process, but being able to mark up a document and then creat various aggregations of the information is a game changer. before I was just linking to the documents, not actually pulling in the text.

Every time I post, there’s a mountain of new stuff to learn. :slight_smile:

I’ll have to get on this one tomorrow as it’s almost 1am where I am…

I have a lot of nested tags, so I need to figure this out, but good to see that it’s possible.

  • There will be times where I actually do want everything that follows the base tag.
    e.g. I want ALL people, i.e. #people and every subtag of people like #people/american & #people/german

  • other times I only want #people/american and nothing else.

  • and other times like above, I only want #people and none of the subtags.

You guys should teach online classes as we non-techies really struggle trying to do our professional work while learning coding and structural stuff that’s way above our pay grade. :slight_smile:

Have a good night and thanks again.

1 Like

just to be sure I’ve got it right, is this what you mean?

TABLE WITHOUT ID link(file.link, Title) AS "Title", Aliases, Occupation, Employment, Born, Death, Birthplace, Note
FROM #note/type/person AND -"Templates"
WHERE econtains(file.etags, "#note/type/person")
SORT file.link ASC

do I need the FROM #note/type/person as well or just like this?

TABLE WITHOUT ID link(file.link, Title) AS "Title", Aliases, Occupation, Employment, Born, Death, Birthplace, Note
FROM -"Templates"
WHERE econtains(file.etags, "#note/type/person")
SORT file.link ASC

What if I want to combine two tags would it look like this?

TABLE WITHOUT ID link(file.link, Title) AS "Title", Aliases, Occupation, Employment, Born, Death, Birthplace, Note
FROM -"Templates"
WHERE econtains(file.etags, "#note/type/person", "pin/person/occupation/politician")
SORT file.link ASC

And lastly, what if I DO want #note/type/person + all of the subtags w/o having to write them all. Do I then revert back to

FROM #note/type/person AND -"Templates"

w/o the etags? It’s all getting a bit confusing to me as this opened up a whole new can of worms! :slight_smile:

One of your ideas here doesn’t work, and if you read the documentation I referred to in previous post, it should be clear which.

As for the others, I think it’s due time to just the various combinations yourself. Make dedicated notes have the specific stuff you need to test for, and some with almost all.

Test your idea, and fiddle about a little. It shouldn’t take too long with all the examples you’ve been given.

Another great tip is to find a way to read to yourself what the various queries say, and see if it makes sense. This is however a little bit of learning to properly read them out, but it can be very helpful.

1 Like

I’m so sorry to go off topic, but could I ask you what theme you’re using? I love the CSS of your table!

I’ve been doing that all along, but it’s a steep learning curve w/ very little time to learn it all. That said, will do all that you suggest! Thanks again!

R

Hello. I’m using the minimal theme with the extra “minimal theme settings” and the “Style settings.” i haven’t done much to change anything except the font size and accent color… it pretty much looks like this out of the box.

@holroy

Well I swear I tried to read that document in full functions dataview in full and it was way over my head… I also tried a 100 variations, but in this more complex setup, it’s not working. It works great in my original setup.

I want to limit the results so that dataview doesn’t return subtags. The following code still returns #pin/topic/test/subcategory. I tried various placements of the “econtains” line as well. I also tried replacing “file” with “item” and other guesses. If you’re so inclined, would love to know what isn’t right in this use-case. cheers.

relatedly, when I’m wanting to return only the quotes that have BOTH tags, it works if one of the quotes is not a direct subtag of the other (even though they are both subtags of the previous level)

but if they are direct subtags of each other, then I get both quotes, which is an OR situation. I will also want to do an OR situation at times, and if so, is this the proper way?:

I tried it w/ econtains as well, but that gave me no results. e.g.

Table 
  item.Quote as Quote,
  item.Source as Source,
  item.Topic as Topic
FROM -"Templates" AND -"_Inbox"  
FLATTEN file.lists as item
WHERE item.Quote
  AND econtains(file.etags, "#pin/topic/test/science")
  AND econtains(file.etags, "#pin/topic/test")
Sort item.source ASC

Thanks in advance!!

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