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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
WTreadway
Frequent Visitor

How do I create a measure that filters with "AND" and "OR" Conditions from many different tables.

Hello,

I am trying to create a measure the aggregrates Net Balance but we need to filter that on a few different conditions.
We have three Tables:
Balance (Factish table), Cost Center (DIM), Account(DIM).

The business logic is: Sum all Net Balances where:

Balance Type is "Actual", the Cost Center Parent is "Sales" and the Acct 5 is "OP"

or

Balance Type is "Actual", the Cost Center Code is "2202", and the Acct 5 is "OP

or

Balance Type is "Actual", Acct 6 is "Other"

 

My Dax is =

Actual Sales Expense = CALCULATE(SUM('GL Balances'[Period Net Balance]),'GL Balances'[Balance Type] = "ACTUAL", Filter(Account,Account[Acct 5]  = "Cost of Operation" || Account[Acct 6] = "Other"),Filter('Cost Center','Cost Center'[Cost Center Code] = "2202" || 'Cost Center'[Cost Center Parent] = "Sales"))

But this doesn't seem to work, I think I am getting other comibantion that aren't intended.
I tried to write the DAX like this:
CALCULATE ( SUM ( 'Balance'[Net Balance] ), 'Balance'[Balance Type] = "ACTUAL" && 'Cost Center'[Cost Center Parent] = "Sales" && 'Balance'[Acct 5] = "OP" || 'Balance'[Balance Type] = "ACTUAL" && 'Balance'[Cost Center Code] = "2202" && 'Balance'[Acct 5] = ",OP" || 'Balance'[Balance Type] = "ACTUAL" && 'Balance'[Acct 6] = "Other")

However, this doesn't not work. I get the following:

WTreadway_0-1692128472630.png


Any help or direction on this would be great. Thanks in advanced. 

1 ACCEPTED SOLUTION

This did not work. Still have the same issue. I solve this by create a Variable in my measure to hold each criteria groups. Then return the Variables added together.

Measure = 
var _Cat1 = Cat 1 logic

var _Cat2 = Cat 2 logic

var _Cat3 = Cat 3 logic

 

return

(_Cat1 + _Cat2 + _Cat3)

View solution in original post

2 REPLIES 2
AnthonyGenovese
Resolver III
Resolver III

Don't use Filter, do the following instead

 

Actual Sales Expense =
 SUM( 'GL Balances'[Period Net Balance] ),
'GL Balances'[Balance Type] = "ACTUAL",
OR(
Account[Acct 5] = "Cost of Operation",
Account[Acct 6] = "Other"
),
OR(
'Cost Center'[Cost Center Code] = "2202"
,'Cost Center'[Cost Center Parent] = "Sales"
)
)

If this post was helpful, please kudos or accept the answer as a solution.
~ Anthony Genovese
Need more PBI help? PM me for affordable, dedicated training or consultant recomendations!

This did not work. Still have the same issue. I solve this by create a Variable in my measure to hold each criteria groups. Then return the Variables added together.

Measure = 
var _Cat1 = Cat 1 logic

var _Cat2 = Cat 2 logic

var _Cat3 = Cat 3 logic

 

return

(_Cat1 + _Cat2 + _Cat3)

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.