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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
TommyNguyen
New Member

Help understanding the function VALUES when passed as a filter parameter in Calculation in Dax

Hi everyone, I want to display the revenue of each product where its productID is greater than 10. I have a Dax formula as bellow:

 

Revenue of productID greater than 10 :=  CALCULATE(Sales[Sum revenue],'Product'[ProductID]>10))

 

 

This return a table that is not as expected because the revenue is the same with all productIDs:

TommyNguyen_1-1639147260354.png

When I modify the Dax to:

 

Revenue of productID greater than 10 = 
Var productIDContext = VALUES('Product'[ProductID])
return CALCULATE(Sales[Sum revenue],'Product'[ProductID]>10,productIDContext)

 

It returns the result as expected

TommyNguyen_2-1639148192852.png

In conclusion, I want to what variable productIDContext is really doing in this Dax formulae, it seems that the filter: 'Product'[ProductID]>10  has overwritten the filter context of productID outside the calculation function so we need productIDContext to regain it, but I still could not understand exactly the under the mechanism of Dax to merge the initial filter context of productID outside the Calculate function and 2 filter parameters inside the Calculate function. Can someones please explain this to me? Sorry for my bad english.

1 ACCEPTED SOLUTION
bcdobbs
Community Champion
Community Champion

Hi,

When you write 

CALCULATE(
  [Sum revenue],
  'Product'[ProductID]>10
)

 

DAX actually goes away and does this:

CALCULATE(
  [Sum revenue],
  FILTER(
    ALL('Product'[ProductID]),
    'Product'[ProductId] > 10
  )
)

 eg it removes any existing filters on product id (eg the ones coming from the matrix rows and then it adds a new filter to just get ids greater than 10.

 

In the measure that is working it does the same but VALUES('Product'[ProductId]) add back the existing Product Ids that were in the filter context to start with.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

3 REPLIES 3
TommyNguyen
New Member

Thanks for you your support

bcdobbs
Community Champion
Community Champion

Hi,

When you write 

CALCULATE(
  [Sum revenue],
  'Product'[ProductID]>10
)

 

DAX actually goes away and does this:

CALCULATE(
  [Sum revenue],
  FILTER(
    ALL('Product'[ProductID]),
    'Product'[ProductId] > 10
  )
)

 eg it removes any existing filters on product id (eg the ones coming from the matrix rows and then it adds a new filter to just get ids greater than 10.

 

In the measure that is working it does the same but VALUES('Product'[ProductId]) add back the existing Product Ids that were in the filter context to start with.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

@bcdobbs is correct. VALUES is restoring the local ProductId filter context that CALCULATE replaces.

 

I just wanted to suggest using KEEPFILTERS in your measure like this rather than VALUES:

CALCULATE (
    Sales[Sum revenue],
    KEEPFILTERS ( 'Product'[ProductID] > 10 )
)

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.