In DataviewJS, how can I filter pages with a specific property / field that contains spaces?

I did a bunch of looking up about this but didn’t find answers. Let’s say I have a properties like these in a note, both are valid texts properties:

Task Size: Large
Status: Not started.

And I have DataviewJS like this, that filters to only pages in the “Tasks” folder and its Status property is not “Waiting”:

const { fieldModifier: f } =["metadata-menu"].api;

    "Task Size"], 
    await Promise.all(
        dv.pages('"Tasks"').where(p => p.Status != 'Waiting')
            .sort(b => -b.AtomicID)
            .map(async d => [
                f(dv, d, "Task Size")

How could I add another filter in where() for pages where the “Task Started” properties is not “Large”?

For properties with a space, you enclose them in square brackets and quotes, like this:

p['Task Size']

So your full where would be:

where(p => p.Status != 'Waiting' && p['Task Size'] !== 'Large')

Here’s a 101 intro into JavaScript objects and properties:

(it was the first link on Google, but looks good)


Oh I see where I went wrong: I didn’t escape the quotes when writing it as an argument inside dv.view() {key: "value"}, It should’ve been p[\'Task Size\']. But honestly Dataview could use better stack tracking, and or I need to read it better.

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