Simple table with two variables on the same page not sorting

What I’m trying to do

I have two Variables: Entity :: (name String) and Initiative :: (number). for every Entity there is a initiative directly below it.

I want to make a table with both variables in it sorted by initiative ASC.

Things I have tried

My table currently looks like code below. The variables display properly but are not sorted by Initiative.

TABLE Entity,Initiative
WHERE file.name = this.file.name
SORT Initiative ASC

the text displays like below:

Column 1 Column 2 Column 3
File1 Entity Initiative
S1 First Fight Fred Goblin Grunt 0
Fern Goblin Grunt 4
Lemoncream Great Horned Owlbear 1
Steven, Stephan, and Streve Goblin Scum 0
Player 1 0
Player 2 20
Player 3 0

my note is setup looking like below:

Entity :: Name

Initiative :: 0

Entity :: Name

Initiative :: 0
…etc.

still pretty new to dataview and don’t know exactly what I am doing wrong.

In column 1 you can see that your table actually only has two rows. One row for “File 1”, and one row for the file “S1 First Fight”. The second row consists a file name in the first column, and then two separate lists in the following columns.

When you just place two fields on following lines in your files, they’re not actually connected to each other as seen from Dataview. To get that effect you’ll need to have the fields in a list item like:

- [Entity:: Fred Goblin Grunt] [Initiative:: 0]

And use queries like:

```dataview
TABLE item.entity as Entity, item.initiative as Initiative
WHERE file = this.file
FLATTEN file.lists as item
WHERE item.entity
SORT item.initiative ASC
```

Which would then list all the entities defined in that particular file. This works since we’re using FLATTEN file.lists as item to separate the entities into their own row in the table. If you tried doing FLATTEN initiative as something you’d loose the connection to which entity it belongs to.

Thanks! This works great. Clean and efficient. I just wish I could edit the individual values easier.

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