Search code examples
powerbidaxdata-analysispowerbi-desktopmeasure

What is the difference between using Table vs Column in DAX FILTER?


Assuming my model has following tables: Date, Product, Sales

Say this is a star schema with date and product filtering the Sales table.

I'm trying to visualise what the following does:

Filter on ALL Date column:

CALCULATE (
    SUM ( Movements[Quantity] ),
    FILTER (
        ALL ( 'Date'[Date] ),
        'Date'[Date] < DATE ( 2013, 1, 1)
    )
)

Filter on ALL date table:

CALCULATE (
    SUM ( Movements[Quantity] ),
    FILTER (
        ALL ( 'Date' ),
        'Date'[Date] < DATE ( 2013, 1, 1)
    )
)

Prior to the formula evaluation, there is the Date table that filters the Sales table. There can be multiple slicers on the report to further add filter context.

So the above tables the filtered or unfiltered Date table?

Does the Date table get entirely replaced with the filter context generated by the above DAX?

What's the difference between using table vs column in the FILTER? That is - Date vs Date[Date]


Solution

  • In the case of date tables, there is no difference in your example. To quote from the following: https://www.sqlbi.com/articles/mark-as-date-table/

    In order to simplify the usage of time intelligence functions, the DAX engine makes an assumption when two tables are related through a column of Date data type: When a filter is applied on the key of the relationship – Date[Date] in this example – the new filter overrides any other filter on the Date table. It basically applies a REMOVEFILTERS ( Date ) to the filter context every time you apply a filter on the Date[Date] column. This behavior occurs automatically only when the relationship is based on a column of Date data type.

    You can obtain the same behavior – that is, adding REMOVEFILTERS on the table whenever a new filter is applied on the Date column – by marking the table as a date table. When you mark a table as a date table, Power BI asks which column contains the dates of the calendar. This is required because the engine adds REMOVEFILTERS every time you apply a filter on that specific column.