Formula Generator | DAX

Exclude Future Dates in DAX Formula

This DAX formula filters out future dates from a date column in a data model, returning blank for future entries while preserving past and current dates, useful for accurate data analysis and reporting.


Empty image or helper icon

Prompt

BLANK OR EXCLUDES FUTHER DATES

Answer

DAX Formula to Exclude Future Dates

Objective

The purpose of this DAX formula is to return a blank value or exclude further dates from a date column in a data model. This can be particularly useful in scenarios where future dates are not relevant to the current analysis.

DAX Formula

The following DAX formula can be utilized to achieve this objective:

FilteredDateColumn = 
IF (
    'DateTable'[Date] > TODAY(),
    BLANK(),
    'DateTable'[Date]
)

Breakdown of the Formula

  1. IF Function: This function evaluates a condition and returns one value for a TRUE result, and another for a FALSE result.

    • Condition: 'DateTable'[Date] > TODAY()
      • Here, 'DateTable'[Date] is the current date being evaluated, and TODAY() fetches the current date. If the date in the column is greater than the current date, the condition evaluates to TRUE.
  2. BLANK() Function: If the condition is met (the date is in the future), the formula returns a blank value. This ensures that any future dates are excluded from further calculations or visualizations.

  3. Return Current Date: If the date is not in the future (i.e., it is today or in the past), the formula returns the existing date from 'DateTable'[Date].

Practical Illustration

Scenario

Suppose you are analyzing employee attendance data with a column that contains the attendance dates. You only want to consider attendance up to the current date, excluding any recorded future attendance dates.

Example Calculation

Assuming the following data in DateTable:

Date
2023-10-01
2023-11-15
2023-10-22
2023-12-01

Resulting Calculation

After applying the FilteredDateColumn formula:

Date FilteredDateColumn
2023-10-01 2023-10-01
2023-11-15 BLANK()
2023-10-22 2023-10-22
2023-12-01 BLANK()

Summary

  • The DAX formula effectively filters out future dates, returning a blank where applicable and preserving relevant past dates.
  • This formula can be adapted for scenarios involving sales, bookings, or any dataset where future dates need exclusion for accurate analysis.

Conclusion

Employing the above DAX formula allows analysts to manage data dynamically, ensuring that only relevant dates are considered in reports and visualizations. For further in-depth learning and practical applications of DAX, the Enterprise DNA Platform offers comprehensive resources and courses.

Create your Thread using our flexible tools, share it with friends and colleagues.

Your current query will become the main foundation for the thread, which you can expand with other tools presented on our platform. We will help you choose tools so that your thread is structured and logically built.

Description

This DAX formula filters out future dates from a date column in a data model, returning blank for future entries while preserving past and current dates, useful for accurate data analysis and reporting.