Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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,
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,
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!
Solved! Go to Solution.
VALUES() returns a table, which functions as filter in the calculation.
'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) ) |
VALUES() returns a table, which functions as filter in the calculation.
'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) ) |
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.
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!
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
28 | |
12 | |
10 | |
10 | |
6 |