Help with a profit chart - some fields are "null"

You can try using $ifNull maybe to see if that works for you in Charts. I created a simple example on the 3 test documents that had appropriate missing fields.Revenue and fields.Cost values but i’d highly recommend testing this out to see if it works for your 400k+ documents on a test namespace.

The pipeline:

[{$set: {
  'fields.Revenue': {$ifNull:['$fields.Revenue', 0]},
  'fields.Cost': {$ifNull:['$fields.Cost', 0]}
}}]

Applied at Charts datasource:

Then using the Calculated field mentioned in my previous reply:

Then converting the date string field to Date data type and placing on the axis’s:

Regards,
Jason

1 Like