We already talked several times about the blank row in DAX: here, here, and here. The blank row is needed to accommodate invalid relationships. Its presence may be a symptom of a problem in your model, or it may exist just because of some missing data.

Specifically, the blank row appears in a model when the many-side of a relationship contains a value that is not present among the keys on the one side. For example, it will appear if Sales references a customer key that is not present in the Customer table.

However, one specific value can legitimately be present in Sales, and still trigger the blank row: BLANK. If a row in Sales contains BLANK for the customer key, Power BI creates the blank row to relate blank values with the blank row.

If you do not want the blank row in Customer, you can create a row in Customer with a dummy CustomerKey value, like -1, and replace blanks in Sales with -1. The main advantage of this approach is that you have control over the content of the dummy row: instead of showing blank, you can show a dummy customer name, like “<NO CUSTOMER>”.

However, there is a special scenario where this option is not available: Date. If you use a DateTime column to relate Sales with Date, the presence of BLANK in any row in Sales triggers the blank row in Date, as expected. Adding a dummy date to Date is not as simple as it is for Customer because you need a numeric value for the key (dates are stored as floating-point numbers), so you end up storing a valid date in the database, rather than a dummy date. For example, 0 as a DateTime, is 12/30/1899, -1 is 12/29/1899, and so on. Therefore, BLANK is not an option, as it forces the presence of the blank row; any other number is not an option either, because it is a valid date. If you want to create dummy dates in the Date table, then you need to revert to using an integer to create the relationship between Date and Sales. With an integer, you can use -1 as the key and BLANK in the Date column in the Date table.

Unfortunately, this has a nasty side effect: storing BLANK in the Date column prevents you from using the “Mark as a date table” feature, because the column tagged as the date column cannot contain blanks.

The good news is that “Mark as a date table” is useful when you rely on classic time intelligence. When using Calendar-based time intelligence, “Mark as a date table” is no longer required. Be mindful that Power BI claims that “Mark as a date table” is not recommended, as you can see in the user interface above. However, “Mark as a date table” is a useful feature, and we at SQLBI recommend using it whenever you rely on classic time intelligence. When using calendar-based time intelligence, mark as a date table is just not needed.

Therefore, if you want to add a dummy row to Date to handle empty dates by yourself, rather than relying on the automatic blank row, you need both:

  • An integer to relate any date in fact tables to the Date table
  • Calendar-based time intelligence rather than classic time intelligence

Once these two requisites are met, you can safely add a dummy row and control how empty values are displayed. For example, in the following figure we used N/A rather than blank to show values for which the orders are not delivered yet.

Be mindful that when Date[Date] contains blanks, the Power BI user interface shows errors that you can safely ignore – provided that you handle the peculiarities that appear because of that blank date, as we shall describe later on in this piece.

A blank date in Date[Date] requires special attention. In DAX, BLANK equals zero. Therefore, BLANK, as a date, is considered 12/30/1899. However, in calendar-based time intelligence, the engine does not treat the Date column as a date; it uses individual columns to build hierarchies in the Date table. In our model, dates span from 2022 to 2026. The string N/A appears later than 2026 because letters come after numbers in standard sort order. Therefore, from a DAX standpoint, N/A is a valid year that comes after 2026.

If a developer creates a formula like the following:

Measure in Sales table
Delivery PY = 
CALCULATE ( 
    [Delivery Amount], 
    DATEADD ( 'Gregorian', -1, YEAR )
)

The result is that for N/A the report will show the Delivery Amount of 2026, which is the year before.

Showing 238.555,05 for Delivery PY in the N/A row is misleading, to say the least. Moving the N/A row to the top by sorting the Year column by year number solves one problem, but it introduces another. N/A as the first year would produce a value for Delivery PY in 2022, where we would like to see a correct blank instead.

The easiest way to overcome this issue is to remove the dummy row from Date before performing any time intelligence calculation, so to make sure that the dummy row is handled in the special way it deserves:

Measure in Sales table
Delivery PY Corrected = 
CALCULATE (
    CALCULATE ( 
        [Delivery Amount], 
        DATEADD ( 'Gregorian', -1, YEAR ),
        KEEPFILTERS ( NOT ISBLANK ( 'Date'[Date] ) )
    ),
    KEEPFILTERS ( NOT ISBLANK ( 'Date'[Date] ) )
)

The new measure hides the value for the dummy row.

The double filter for NOT ISBLANK is required to handle scenarios where the dummy year is at the beginning or at the end of the period. Indeed, the dummy row needs to be ignored both for the source and the destination filters created by DATEADD.

Because the pattern is likely to be used multiple times, the best option is to create a function to handle this:

Function
 ProtectFromDummyDate = (
        formulaExpr : EXPR,
        filterExpr : EXPR
    ) =>
    CALCULATE (
        CALCULATE (
            formulaExpr,
            filterExpr,
            KEEPFILTERS ( NOT ISBLANK ( 'Date'[Date] ) )
        ),
        KEEPFILTERS ( NOT ISBLANK ( 'Date'[Date] ) )
    )

This way, the measure becomes much simpler:

Measure in Sales table
Delivery PY Corrected = 
    ProtectFromDummyDate ( [Delivery Amount], DATEADD ( 'Gregorian', -1, YEAR ) )

This pattern can be used for any time-intelligence calculation.

Conclusions

The blank row is needed whenever a relationship is invalid; this includes the presence of BLANK in any row on the many-side of the relationship. Using a dummy date is not an option with classic time intelligence, whereas it becomes an opportunity with the new calendar-based time intelligence.

The main advantage is controlling the content and placement of the blank row; the dummy date is a custom replacement for the automatically-created blank row. One advantage of this technique is that you can define multiple dummy dates – one to indicate orders not delivered yet, one to indicate the presence of an error, and so on.

Although dummy dates provide more flexibility for the data modeler, they require special handling whenever you use a time intelligence calculation. Functions are very helpful here, as they let developers put complex code into a common factor and reuse it for different measures.

BLANK

Returns a blank.

BLANK ( )

ISBLANK

Checks whether a value is blank, and returns TRUE or FALSE.

ISBLANK ( <Value> )

DATEADD
Context transition

Moves the given set of dates by a specified interval.

DATEADD ( <Dates>, <NumberOfIntervals>, <Interval> [, <Extension>] [, <Truncation>] )