Dataview plugin groupBy multiple items

Things I have tried

Hello I’m having a field inside my notes called: Planets::

And in most cases, I do have only one value against that field. However, some of the scenarios can have multiple values like:
Planets:: Value 1, Value 2

The following code creates proper groups for a single value, but when the values are two it creates a new group called: “Value 1, Value 2”.

What I’m looking for is to have the notes in both groups: Value 1 and Value 2 duplicated. Can you please assist me?

P.S.
Also, I’m wondering whether or not I can have a field like “Two Words::”, and access it inside the groupBy code. Right now I had to change the name of the field to “Two_Words::”, so that I can access it via "groupBy(p => p.two_words).

What I’m trying to do

And here is the code that I’m trying to make it work:


dv.header(6, "Number of Problems: " + dv.pages("#problem and -#template").length)


for (let planet of dv.pages("#problem and -#template").groupBy(p => p.Planets)) {
	dv.header(2, planet.key)
	
	for (let problem of dv.array(planet.rows).groupBy(p => p.Knowledge_Labs)) {
		dv.header(3, problem.key);
		dv.table(["Name", "Complexity"],
		problem.rows
			.sort(k => k.Complexity, 'desc')
			.map(k => [k.file.link, k.Complexity]))
	}
	
}
1 Like

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