If Statement In Dataviewjs

Greetings All,

I am currently using the Obsidian DB Folder plugin to keep track of my tv library. I am trying to figure out how to put in a formula column (which uses dataviewjs) how to join two date columns together with if else statements. I am stumped on how to do this, as I am new to dataview/dataviewjs. I come from the world of Notion. I have looked at the documentation, but find it difficult to wrap my head around it.

WHAT I’M LOOKING TO DO:

  • Return the value of the column “series_start_year” (which has the first air date for the television series) into a column that says “series_dates”. However, if the “series_start_year” column is empty, then the “series_dates” column should remain blank/empty and not report anything.
  • Return the value of the column “series_end_year” (which would have the end air date for the television series) into a column that says “series_dates”. However, if this column is blank for the entry, it should report as “Present”.

The goal is for the “series_dates” column is to look like this:

  • Empty (The “series_start_year” and the "series_end_year columns are empty.)
  • DATE → Present (The “series_start_year” column has a date in it, but the “series_end_year” column does not.)
  • DATE → DATE ( The “series_start_year” and “series_end_year’” columns have dates in them.)

Please show your query so far, so that we know what we’re working with. That will make it easier to give more precise answers.

This is what I have so far.

${row.series_start_year.toFormat(“DDDD”)} →

That is a single column, not the entire or anything resembling a query…

I can go as further as:

${row.series_start_year.toFormat(“DDDD”)} → ${row.series_end_year.toFormat(“DDDD”)}

I know to a degree it will work, however, it does not give me the result of what I truly intend to achieve and in most cases it fails.

I don’t mind doing more research. However, I hope that I can be pointed in the right direction. Or, given some good detailed examples so I can understand what it going on in the coding.

I appreciate any further assistance!

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