Easier way to write somewhat complex inline dataview queries

What I’m trying to do

Find an easier way to write somewhat complex in-line dataview queries.

For example, I was able to write the following query that yields a different week number depending on if the day of the week is after Wednesday or not, but it was not easy to trace all the parentheses/nesting.

=dateformat(choice((date(sow) + dur(3 d)) > date(today), date(today) - dur(1 w), date(today)), "W")

Is there any kind of code editor that could be used to make this easier, or is this a situation where I should be using Javascript instead? Any suggestions much appreciated.

You could try to simplify the logic possibly?

Shouldn’t this give the same kind of response: ` dateformat(date(today) - dur(choice(date(today).weekday > 3, 1, 0) + “w”), “W”)`

Or possibly: `= choice(date(today).weekday > 3, date(today), date(today) - dur(1w)).weekyear`

If you wasn’t using an inline query, you could possibly split it into multiple lines, but at the end of the day if you need to nest functions you do need that, and then using parentheses is the way to group stuff.

The first one has a syntax error that I can’t find, but that second one is excellent. I didn’t know I could pull weekday and weekyear out of the date like that. I guess I just need to gain more familiarity with the language to find simpler ways of doing things.