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
Marcus_E
Helper I
Helper I

Multiple measure AND conditions

Hi

 

I'm trying to eliminate unnecessary slicers on my report page by filtering key outputs using measures but am struggling combining multiple AND conditions within the measure.

 

The scenario is:

Table1: [Transaction_Name][Quantity]

Table2: [Resource_Type][Resource_Description]

 

I've tried writing the following measure that will output a sum of the [Quantity] column where a) the Quantities are greater than 0 AND the [Resource_Description] in a separate linked table = "Contractors". 

 

This is what I've tried:

Measure (Quantity Total) =
CALCULATE (
SUM (Transaction_Name[Quantity]) ,
FILTER(Transaction_Name, Transaction_Name[Quantity] > 0) &&
FILTER(Resource_Type, [Resource_Type][Resource_Description] = "Contractors"))

 

Unfortunately I keep getting an error: 'A function 'FILTER' has been used in a TRUE / FALSE expression that is used as a table filter expression'. Have tried a number of different iterations of the expression but can't get it to work with multiple conditions.

 

I know it should be straight forward but I just can't work out how to apply filters from different tables.

 

Anyone with any suggestions would be appreciated. Thanks.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Marcus_E , Try one of three


Measure (Quantity Total) =
CALCULATE (
SUM (Transaction_Name[Quantity]) ,
FILTER(Transaction_Name, Transaction_Name[Quantity] > 0) ,
FILTER(Resource_Type, Resource_Type[Resource_Description] = "Contractors"))

Measure (Quantity Total) =
CALCULATE (
SUM (Transaction_Name[Quantity]) ,
Transaction_Name[Quantity] > 0 && Resource_Type[Resource_Description] = "Contractors")


Measure (Quantity Total) =
CALCULATE (
SUM (Transaction_Name[Quantity]) ,
FILTER(Transaction_Name, Transaction_Name[Quantity] > 0) , Resource_Type[Resource_Description] = "Contractors")

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

@Marcus_E , Try one of three


Measure (Quantity Total) =
CALCULATE (
SUM (Transaction_Name[Quantity]) ,
FILTER(Transaction_Name, Transaction_Name[Quantity] > 0) ,
FILTER(Resource_Type, Resource_Type[Resource_Description] = "Contractors"))

Measure (Quantity Total) =
CALCULATE (
SUM (Transaction_Name[Quantity]) ,
Transaction_Name[Quantity] > 0 && Resource_Type[Resource_Description] = "Contractors")


Measure (Quantity Total) =
CALCULATE (
SUM (Transaction_Name[Quantity]) ,
FILTER(Transaction_Name, Transaction_Name[Quantity] > 0) , Resource_Type[Resource_Description] = "Contractors")

Thank you, both of these solutions work perfectly.

You are welcome.  If my reply helped, please mark it as Answer.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Ashish_Mathur
Super User
Super User

Hi,

Does this work?

Measure (Quantity Total) = CALCULATE(SUM('Transaction_Name'[Quantity]),FILTER('Transaction_Name', 'Transaction_Name'[Quantity]>0),FILTER('Resource_Type','Resource_Type'[Resource_Description] = "Contractors"))
If it does not help, then share the link from where i can download your PBI file.

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.