How to handle null values in dates when calculating on dates

Note: This article doens't explain how to do general calculations on dates - that's explained here: Date calculations – TARGIT Community

Once you figured out how to calculate on dates, using the referenced documentation above, you can end up with a math error if one of the dates you reference contains Nulls

See example below:

 

The math error can't be fixed directly, since there is no way of testing for Nulls in dimension values in the syntax.

However the Math errors can be referenced - so we could start out by validating our 2 dates (1 at the time in this example).

 

 

Now we have math errors, which indicates Null values. If one of the Dates holds Null values, the calculation result should be blank.

To achieve that, this syntax tests (by using the 4th parameter) if any of my calculated columns gives a math error. 
Note: See this article for details on the 4th parameter: The 4th parameter – TARGIT Community

If this is the case, we enter a dummy value, else we do subtract the 2 columns and get the right number of days.

Syntax: if sum(c1, 0, m1, 0) = 0 or sum(c2, 0, m1, 0) = 0 then 9999 else sum(c2, 0, m1) - sum(c1, 0, m1)

Now we have this result:

Finally we add a visibility agent to hide values = 9999. and hides the intermediate calculations - that gives us a perfect table:

 

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.