Sub topic 13
Checking the table and fixing common problems
This chapter assumes you have built a date table with DAX or Power Query, related it to a fact table, marked it as the date table, and written basic time intelligence measures. Here you check that the table works and diagnose the usual failures.
Check the table itself
Start with the date table, before you look at any measure. Four checks catch most problems.
- No gaps. Every day between the first and last date must appear once.
- No duplicates. The date column must be unique, with no blanks.
- Date type. The column must have the Date data type, not Date/Time or text.
- Full years. The table must start on January 1 and end on December 31 (or the fiscal equivalents).
You can test the first two with a measure in a card visual:
Date Row Count = COUNTROWS ( 'Date' )
Expected Days =
VAR FirstDay = MIN ( 'Date'[Date] )
VAR LastDay = MAX ( 'Date'[Date] )
RETURN
DATEDIFF ( FirstDay, LastDay, DAY ) + 1
Date Table Is Complete =
IF ( [Date Row Count] = [Expected Days], "OK", "Gaps or duplicates" )If the row count differs from the expected days, the table has gaps or duplicate dates.
Check the coverage of the facts
The date table must cover every date in the fact table. Rows that fall outside it relate to a blank member, and their values appear under a blank date in visuals. This measure counts them:
Sales Without Valid Date =
CALCULATE (
COUNTROWS ( Sales ),
ISBLANK ( RELATED ( 'Date'[Date] ) )
)A non-zero result means the date range is too narrow, or the fact table holds a date with a time part or a null value. If the fact column is Date/Time, convert it to Date in Power Query so that values with a time of day still match a whole day.
Follow the flow of a diagnosis
The diagram shows the order in which to look for causes when a time intelligence measure returns a wrong or blank result.
Common problems and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Marking the table fails with a duplicate or blank error | The date column has repeated or empty values | Remove duplicates and blanks, or rebuild the table |
| Month names appear alphabetically | No sort-by-column is set | Sort `Month` by `Month Number`, and `Year-Month` is already sortable as text |
| Year-to-date returns the same value as the total | The measure uses the fact table date, or the relationship is missing | Pass `'Date'[Date]` to the function and check the relationship |
| Same period last year is blank | The prior year is missing from the date table | Extend the calendar range |
| Year-to-date does not reset on July 1 | The fiscal year-end argument is missing | Pass `"6/30"` as the third argument of `TOTALYTD` |
| Ship date measure equals the order date measure | The second relationship is still inactive | Use `USERELATIONSHIP` in the measure |
| A blank row appears in a date slicer | Fact dates fall outside the date table | Widen the range, then re-check coverage |
Watch for these traps
Also check that only one date table is marked. Marking a second table does not stop the first from working, but it leaves you with two calendars that can disagree. Keep one date table, and relate every fact table to it.
Test with a small matrix
Place Year and Month on the rows of a matrix, and add Total Sales, Sales YTD, and Sales PY. Then read it against three expectations:
- January's
Sales YTDequals January'sTotal Sales. - December's
Sales YTDequals the year's total. - Each
Sales PYvalue equals theTotal Salesof the same month one year earlier.
If all three hold, the table, the relationship, and the measures work together.
Exercise
A matrix shows Sales YTD equal to Total Sales for every month, and the measure is TOTALYTD ( [Total Sales], Sales[OrderDate] ). What is wrong, and what is the fix?
Show answer
The measure passes the fact table's date column instead of the date table's column. The fact column has repeated and missing dates, so the year-to-date filter does not accumulate. Change it to TOTALYTD ( [Total Sales], 'Date'[Date] ) and confirm that the date table is related to Sales and marked as the date table.
Exercise
Your Date Row Count measure returns 2,557 and Expected Days returns 2,558. What does this tell you, and what do you check next?
Show answer
The table is missing one day, or it has a gap, because the number of rows is lower than the number of days between the first and last dates. Check how the table was built, for example a filtered list or a manual edit, and rebuild the range with CALENDAR or List.Dates so that every day is included.