Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
HungFan
Regular Visitor

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 argument in CALCULATE. The V1 code as follows,

 

AllSalesCurrentYear V1 = 
CALCULATE(
        [Sales Amount],
        ALL('Sales'),
        VALUES('Date'[Year])
)

 

I know that VALUES only return the list of values of a column in the current filter context. But for me, it seems a bit weird to only use VALUES('Date'[Year]) as a filter argument. The reason is that the output of VALUES('Date'[Year]) is a unique list like the photo below,

Vules-Date_Year.png

I thought the code shall change to 'Date'[Year] IN VALUES('Date'[Year]) that makes more sense for me. And then after trying the code, I found those result are the same. The V2 code is as follows,

 

AllSalesCurrentYear V2 =
CALCULATE(
        [Sales Amount],
        ALL('Sales'),
        'Date'[Year] IN VALUES('Date'[Year])
)

 

The matrix is as follows,

AllSalesCurrentYear.png

Does anyone has a better understanding of the V1 code? How to explain for people that can only use VALUES('Date'[Year]) as a filter argument for this case.

Thanks!

1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

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] ) )

 



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



View solution in original post

3 REPLIES 3
ThxAlot
Super User
Super User

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] ) )

 



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Jihwan_Kim
Super User
Super User

Hi,

In my opinion, in DAX Studio, it shows all years because there is no filter context.

In the table visualization, there is a filter context in each column, and in the 2007 column, for instance, VALUES ('Date[Year] ) = 2007.

I hope this explains.

Thank you.

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Hi @Jihwan_Kim ,

Thanks for the explaination. However, my question is more like how to explain why can only use VALUES('Date'[Year]) as a filter argument unless it's a modifier like ALL. Normal predicate(filter argument) are like,

 

'Product'[Color] = "Red" or
'Date'[Year] = 2008

 

That's why I said using the code of 'Date'[Year] IN VALUES('Date'[Year]) makes more sense for me. Can you get my point of view? Thanks!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.