Intro
This is my first post and I have never interacted in the forum (as you can see from my account…), yet I always find incredibly useful information on almost every post I read.
Since I’ve had this problem for such a while now, I wanted to post my solution also because I have never found useful code on the internet.
Probably my solution is not optimal, yet works for what I need.
Also: as you can maybe understand from my english, it is not my first language. So you will find some italian words in the code and maybe some grammatical error here and there… 
AUTOMATIC TABLES DIVIDED BY TOPIC (ALSO WORKS FOR LIST OF TOPICS) IN DATAVIEWJS
Problem
I have a lot of programming note (about Python) that has the following YAML structure:
tags: 💾/esempio/python
languageVersion:
difficulty:
topic:
In the note I then include some other information such as Why i created this note, Coding technique used, Code snippet, Code output… But for us that is not important.
What matters is that I have some file with multiple topics! For example I have a note called Python - string into list in which the YAML is as following:
tags: 💾/esempio/python
languageVersion: all
difficulty: beginner
topic: [string, list]
When simply using the .groupBy(p => p.topic)
in dataviewJs, such as following:
for (let group of dv.pages("#💾/esempio/python").groupBy(p => p.topic)) {
dv.header(3, group.key);
dv.table(["Esempio", "Topic", "Versione", "Difficoltà"],
group.rows
.sort(k => k.file.name, 'desc')
.map(k => [k.file.link, k["topic"], k["languageVersion"], k["difficulty"]])
)
}
The result comes as (trimmed for space):
where the file Python - string into list is inserted in a table under another topic:

Solution
After having lost couple of hours searching for some useful code online, i decided to write it myself.
The idea behind it is to first create an array with single topic as entry, then print tables of files (not very different from the above code) containing single element of the array in the topic entry of YAML:
let tag = "#💾/esempio/python"
// **** DATA ARRAY WITH NON REPEATING TOPIC****
// Every element of array is a single topic
// It contains all the entry of 'topic' inserted in all the notes (so, with repetition)
let topics = dv.pages(tag).topic
// *****************************************************
// CREATE ARRAY WITH SINGLE TOPIC AS ELEMENT SUCH THAT THERE IS NO REPETITION
// *****************************************************
let listTopic = []
for (let topic of topics){
//dv.header(1, topic)
//dv.header(2, "--")
if (!listTopic.includes(topic)){
listTopic.push(topic)
}
}
listTopic.sort()
//dv.header(1,listTopic)
// *******************************
// PRINT TABLES OF FILES THAT CONTAINS SINGLE TOPIC IN THE 'topic' ENTRY
// *******************************
// As header is printed the topic, as table all the file containing that topic
let pages = dv.pages(tag)
for (let index of listTopic){
dv.header(3, index);
let pagesIndexed = dv.pages(tag).where(p => (p.topic).includes(index))
dv.table(["Esempio", "Topic", "Versione", "Difficoltà"],
pagesIndexed.sort(k => k.file.name, 'asc')
.map(k => [k.file.link, k["topic"], k["languageVersion"], k["difficulty"]])
)
}
The result is pretty nice:
Conclusion
Probably my code has some imprecisions, and I welcome every tips about that.
Also I still am unsure if that is a problem never solved on the internet. I’ve lost lots of time searching for even partial solution but couldn’t find nothing. If that isn’t the case, let me know.