Multiple Variables per Bullet Point Line in Obsidian — Great Way to Create Questionnaire Item Lists with DataView

«I love it when a plan comes together.»
Hannibal Smith in «The A-Team»

I am currently trying to create a scale. As basis and inspiration, I am looking at other scale items (questions, assertions). Given that I already have a lot of scales in Obsidian, I thought about using DataView. Essentially I want for each scale page all the items and — if relevant — the dimensions or sub-dimensions of the related construct.

As it turns out, Obsidian and DataView can do so, even though the rendering time of a 700+ line table takes a few seconds.

First, I added a folded-in callout box to the scale page. It contains the questionnaire items in a specific syntax that adds the dimension and sub-dimension to each item. As the syntax is not exactly readable, I added the items again, instead of modifying the items already on the page.

As you can see in the following image, each bullet point line contains of the items (Item::) variable and annotated by the dimension (item-dimension::) and sub-dimension (item-sub-dimension). There are multiple of these item lines, as each scale has multiple items, but that’s okay. As part of one bullet point line, the information is connected (e.g., while in the example all items measure «Presence», three are three sub-dimensions («Physical», «Social» and «Self»). BTW, round brackets are used for the variables, so the variable names will not be shown in the DataView table.

or here as code (using the scale from Makransky, G., Lilleholt, L., & Aaby, A. (2017). Development and validation of the Multimodal Presence Scale for virtual reality environments: A confirmatory factor analysis and item response theory approach. Computers in Human Behavior, 72, 276–285.):

> [! scale]- Scale Auto Information
> - Scale-Code:: MPS
> - (Item:: The virtual environment seemed real to me.) (item-dimension:: Presence) (item-sub-dimension:: Physical)
> - (Item:: I had a sense of acting in the virtual environment, rather than operating something from outside.) (item-dimension:: Presence) (item-sub-dimension:: Physical)
> - (Item:: My experience in the virtual environment seemed consistent with my experiences in the real world.) (item-dimension:: Presence) (item-sub-dimension:: Physical)
> - (Item:: While I was in the virtual environment, I had a sense of “being there”.) (item-dimension:: Presence) (item-sub-dimension:: Physical)
> - (Item:: I was completely captivated by the virtual world.) (item-dimension:: Presence) (item-sub-dimension:: Physical)
> - (Item:: I felt like I was in the presence of another person in the virtual environment.) (item-dimension:: Presence) (item-sub-dimension:: Social)
> - (Item:: I felt that the people in the virtual environment were aware of my presence.) (item-dimension:: Presence) (item-sub-dimension:: Social)
> - (Item:: The people in the virtual environment appeared to be sentient (conscious and alive) to me.) (item-dimension:: Presence) (item-sub-dimension:: Social)
> - (Item:: During the simulation there were times where the computer interface seemed to disappear, and I felt like I was working directly with another person.) (item-dimension:: Presence) (item-sub-dimension:: Social)
> - (Item:: I had a sense that I was interacting with other people in the virtual environment, rather than a computer simulation.) (item-dimension:: Presence) (item-sub-dimension:: Social)
> - (Item:: I felt like my virtual embodiment was an extension of my real body within the virtual environment.) (item-dimension:: Presence) (item-sub-dimension:: Self)
> - (Item:: When something happened to my virtual embodiment, it felt like it was happening to my real body.) (item-dimension:: Presence) (item-sub-dimension:: Self)
> - (Item:: I felt like my real arm was projected into the virtual environment through my virtual embodiment.) (item-dimension:: Presence) (item-sub-dimension:: Self)
> - (Item:: I felt like my real hand was inside of the virtual environment.) (item-dimension:: Presence) (item-sub-dimension:: Self)
> - (Item:: During the simulation, I felt like my virtual embodiment and my real body became one and the same.) (item-dimension:: Presence) (item-sub-dimension:: Self)

In the reading/preview mode, you see that the variables are identified (there are in little dark grey boxes).

For the collection page, the following DataView code worked. I am not sure whether a different code would not be faster. DataView is strange, I’m frequently fighting with it, especially when FLATTEN is involved. I used the Obsidian forum discussion https://forum.obsidian.md/t/dataview-multiple-variables-in-the-same-note/77731/ as starting point for the code.

Instead of full page names I have a manually entered Scale-Code, linked with the file.link. And I combined the dimension and sub-dimension in one column, although the sub-dimension is set to “” if it is not assigned (otherwise you have an “-” as result).

or as code:

```dataview
TABLE WITHOUT ID
  link(file.link, Scale-Code) as "Code", "**" + item.item-dimension + choice(item.item-sub-dimension, " - " + item.item-sub-dimension, "") + "**" as "Dim                 ", item.Item as "Item"
  FROM "Skills and Topics/Science - 2 Method Aspects/3 Measurements/3c Measurements - Surveys Questionnaires Scales/Scales"
FLATTEN file.lists as item
WHERE item.Item
SORT Code ASC, item.item-dimension ASC, item.item-sub-dimension ASC, item.Item ASC
```

Generating the table takes a few seconds (700+ lines), but works out very well.

So, overall, it works out pretty well. Exporting the table is an issue, though. You can print it as PDF, but where is the fun in that. Someone mentioned that you can simply use the Developer Tools and copy-paste the whole HTML Table:

Saving DataView Tables
There is a quick and dirty way to save the HTML. The links will work but they won’t count as links on the graph just like normal Dataview tables.
If you press CTRL + SHIFT + I and then click the little mouse arrow icon in the top left of the window that appears, then click on your Dataview table it’ll navigate to the HTML for that table.
Then you just right-click the <table> element and select Copy > Copy outerHTML. Now you can just paste that HTML into a note. If you just want it as a backup you can put it inside a HTML comment and keep using the live Dataview version.
TSPhoenix at https://www.reddit.com/r/ObsidianMD/comments/u766dl/dataview_beyond_obsidian_possible_to_save/?rdt=33506

I tried it out and it works (see View => Toggle Developer Tools for the shortcut, it’s option + command + i on my Mac). You see the starting code block when you hover the mouse over the code and look at what is highlighted in the View. In my table, it was:

<table class="dataview table-view-table">

Simply selecting it and using cmd + c to copy it and pasting it in a text editor worked. So it’s not a data island.So, yeah, quite powerful. That’s the impressive thing with Obsidian — some things just work out. 🙂

Happy using.