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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
SJRJEJ
New Member

Reference current row value in Filter expression

Hi , 
I seem to be struggling with a  problem in PowerBI.
 I will try to explain the issue with the Product and Sales table example .
In my report , I have a drop down filter for Product and I have a Sales table from which I want to display the sales for the Product and also the total sales for the Product Category under which the Item belongs 
 PRODUCT TABLE
ProductCategory Item
BookB1
BookB2
ClothingDress
FurnitureTable
BookB3
ClothingShirt
FurnitureChairs

 

 

SALES TABLE

Item     Sales    ProdCat

B1100Book
Dress20Clothing
B2200Book
Table10Furniture
Shirt30Clothing
B320Book
Chairs60Furniture
 
 
 
SJRJEJ_0-1681714757917.png

 When I hardcode a particular Product Category , the DAX works :

ProductSales = CALCULATE(sum(Sales[Sales]),FILTER(ALL(Sales), Sales[ProdCat] = "Book"))
In the Above DAX , I want to dynamically reference the Product Category of the item selected in the drop down list box .
I tried using EARLIER function to reference the current value of Sales[ProdCat] but I got the below error .
SJRJEJ_1-1681715042155.png

 

 

How do I override the Filter Context and also apply filter based on the current value of the row?

Any advice would be greatly appreciated.

1 ACCEPTED SOLUTION
wdx223_Daniel
Community Champion
Community Champion

=VAR _prdcat=VALUES(Product[ProductCategory]) RETURN CALCULATE(SUM(Sales[Sales]),FILTER(ALL(Product,Product[ProductCategory] IN _prdcat))

View solution in original post

2 REPLIES 2
wdx223_Daniel
Community Champion
Community Champion

=VAR _prdcat=VALUES(Product[ProductCategory]) RETURN CALCULATE(SUM(Sales[Sales]),FILTER(ALL(Product,Product[ProductCategory] IN _prdcat))

Thank you so very much !!!! That worked .

Very grateful for your help .

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.