Forum Discussion

HungFan's avatar
HungFan
Regular Visitor
3 years ago
Solved

Regarding using VALUES as a filter argument in CALCULATE

Hi all, I had learned that writing a measure of AllSalesCurrentYear, especially when computing a percentage over the grand total of only the current year, shall use VALUES('Date'[Year]) as a filter ...
  • ThxAlot's avatar
    3 years ago

    VALUES - DAX Guide

    VALUES() returns a table, which functions as filter in the calculation.

     

    IN - DAX Guide

    'Date'[Year] IN VALUES('Date'[Year]) is syntactic sugar for the CONTAINSROW(), it's interchangeable with

    CONTAINSROW (
        VALUES('Date'[Year]),
        'Date'[Year]
    )

     

    in your case, an alternative to V1 is

    = CALCULATE( [Sales Amount], ALLEXCEPT( 'Sales', 'Date'[Year] ) )