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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sanimesa
Post Prodigy
Post Prodigy

Help with a calculated measure filtered on a column and slicer on same column

I have a very simple example table - purchases from vendors with item number, vendor name, amount and a paid flag (yes/no).

 

I have a measure that calculates the total amount:

Total Cost = SUM(Purchases[Cost])
 
A measure that calculates the total for paid line items:
Total Paid = CALCULATE([Total Cost], Purchases[Paid]="Yes")
 
% Paid = DIVIDE([Total Paid], [Total Cost])
 
I added two filters, one for the vendor, one for the Paid flag. I would expect when I select Paid=No, then the % Paid would be zero. This is not happening. When Paid=Yes, % Paid is correctly shown as 100%. The company fflter is working as expected. 
 
The pbix file is attached.
 
 
 
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

@sanimesa ,

try this measure for Total Paid:

Total Paid =
CALCULATE ( [Total Cost], FILTER ( Purchases, Purchases[Paid] = "Yes" ) )

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

@sanimesa ,

try this measure for Total Paid:

Total Paid =
CALCULATE ( [Total Cost], FILTER ( Purchases, Purchases[Paid] = "Yes" ) )

@Anonymous Thanks a lot, this worked. Why does this work and not the other way around?

Anonymous
Not applicable

@sanimesa,

The original Total Paid measure is overriding the filter context coming from your slicer, essentially it is equivalent of the following formula:

Total Paid = 
CALCULATE ( [Total Cost], FILTER ( ALL ( Purchase[Paid] ), Purchase[Paid] = "Yes" ) )

ALL function ignore any filters coming from your data model. See reference here

@Anonymous Makes sense, thanks. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors