Help with Obsidian Charts and Dataviewjs

Basically what the trickery above does is counting the lines having a CreatedDate in that month.

You correctly changed my typo, so that we get either a list of ["2023-01", 1, 0] if it’s a created date, or ["2023-01", 0, 1] if it’s a closed date. So summing up the one’s, is in effect counting the number of those entries.

The FLATTEN ... as theMonth works indeed as a variable declaration part, and in addition it splits each ticket into two rows. Maybe the following will help you understand some of the magic in the FLATTEN, see Dataview query for all tasks in folder with custom status - #5 by holroy

The fuller explanation of the sum line is as follows:

  • sum( ... ) – Sum all the values in the list within here
    • map( ... , ...) – This function will go through a list, the first parameter, and apply a function, the second parameter, to output another list. We want this to go from a complex list of dates and number, into a single list of numbers, so we do:
      • ( rows.theMonth, ... ) – Use the list of rows.theMonth, and apply the function (as discussed in next item) to each of them. Each of the rows in this list are a list of its own in the format ["2023-01", 1, 0] (or the latter switched around indicate created vs close month)
      • ( ... , (r) => [1] ) – We need to have a name to refer to each row, this is chosen (by me) to be (r). When looking for the created tickets, we need to check the second element (not the date), and since we start indexing on 0, the element we want is r[1]. (For closed tickets, we want the third element, so this then becomes r[2])
  • as Created – The final calculation of the sum of the mapped entries are then stored in another variable, here called Created

Hopefully this make a little more sense, as I’m not sure how to better explain it.