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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Ronak_1
Frequent Visitor

Slicer value to ignore the hardcoded value in measure.

I have a measure which is sum of Total Sales of few selected products which we hardcoded in measure by using IN operator.

Example: 

Sales=CALCULATE(SUM(Sales),Product[Product Name] in {"A","B","C"})
Profit=Calculate(Sum(Profit))

I have a table which displays MonthYear, Sales, Profit. I also have a slicer of "Product" on report. Now when I select one or multiple products I want sales and profit measures to be filtered based on selected product in the slicer. The profit measure works as expected as it does not have product name hardcoded in the measure. 
 
I need help with Sales measure so that the measure value changes based on Product name slicer.
2 REPLIES 2
Ronak_1
Frequent Visitor

I used below measure and it is working fine now in my case.
Sales=CALCULATE(SUM(Sales),Product[Product Name] in {"A","B","C"},Product[Product Name] in VALUES(Product[Product Name]))
Thanks.


amitchandak
Super User
Super User

@Ronak_1 , Try in one of the two ways

 

Sales=CALCULATE(SUM(Sales),filter(Product, Product[Product Name] in {"A","B","C"}) )

 

or

 

Sales=if(isfiltered(Product) , SUM(Sales),

CALCULATE(SUM(Sales),filter(Product, Product[Product Name] in {"A","B","C"}) ) )

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.