Forum Discussion

arunaramana's avatar
arunaramana
Icon for Helper III rankHelper III
4 years ago
Solved

table filter expression in CALCULATE() function

Hello There, As I have gone through microsoft DAX  -- CALCULATE() function documentation, I came across 'Boolean Filter Expression', 'Table Filter Expressions', 'Filter Modification Functions'.   ...
  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi arunaramana ,

     

    =CALCULATE (
        <expression>,
        table[column] = <value>
    )

    In reality the filter expression you wrote is transformed in:

    CALCULATE (
        <expression>,
        FILTER (
            ALL ( table[column] ),
            table[column] = <value>
        )
    )

     

    The FILTER function in DAX is a simple function to use for filtering rows of a table. This function does not change the columns (unless it is used as an input of column manipulation functions such as SELECTCOLUMNS or ADDCOLUMNS). The filter function requires a table input and an expression. The expression should return true or false, and can include AND/OR functions or operators. Similar to many other tabular functions, the main benefit of this function is when used to create a virtual table in a measure expression.

     

    Using a table filter, you inherit the filter argument existing for the  table, so you will not include a value if it was not present in the existing filter. What is more important, you will not override the existing filter on such a column.

     

    https://radacad.com/filter-function-in-dax-and-power-bi-apply-custom-filter-to-calculations

    https://www.sqlbi.com/articles/filter-arguments-in-calculate/

     

    Best Regards,
    Eyelyn Qin
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.