cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sanimesa Member
Member

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

Accepted Solutions
NickNg278 Senior Member
Senior Member

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

@sanimesa ,

try this measure for Total Paid:

Total Paid =
CALCULATE ( [Total Cost], FILTER ( Purchases, Purchases[Paid] = "Yes" ) )
4 REPLIES 4
NickNg278 Senior Member
Senior Member

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

@sanimesa ,

try this measure for Total Paid:

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

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

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

NickNg278 Senior Member
Senior Member

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

@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

Highlighted
sanimesa Member
Member

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

@NickNg278 Makes sense, thanks.