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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Measure that filters across two dimensions

I have these facts and dimensions:

factOrders

dimAddress1

dimAddress2

 

These are the relationships:

dimAddress1 -> factOrders

dimAddress2 -> factOrders

 

I am trying to create a measure that does this:

 

 

Number of Orders with Overseas Addresses :=

DISTINCTCOUNT of factOrders.OrderID

WHERE (dimAddress1.IsOverseas = "Y" OR dimAddress2.IsOverseas = "Y")

 

 

Here is my attempt at the DAX:

 

 

 CALCULATE(
    DISTINCTCOUNT('factOrders'[OrderID]),
    'dimAddress1'[Is Overseas] = "Y" || 'dimAddress2'[Is Overseas] = "Y"
)

 

 

but it gives the error "The expression contains multiple columns, but only a single column can be used in a True/False expression that is used as a table filter expression."

 

Any suggestions?

3 REPLIES 3
Anonymous
Not applicable

// This formula uses this math formula for sets:
// |A + B| = |A| + |B| - |A * B|
// Since the formula does not use OR, it
// might be faster... but can't guarantee it.

# Overeas Orders :=
var __ordersWithOverseasAddr1 = 
	calculate(
		distinctcount( factOrders[OrderId] ),
		keepfilters( dimAddress1.IsOverseas = "Y" )
	)
var __ordersWithAverseasAddr2 =
	calculate(
		distinctcount( factOrders[OrderId] ),
		keepfilters( dimAddress2.IsOverseas = "Y" )
	)
var __ordersWithBothAddrOverseas =
	calculate(
		distinctcount( factOrders[OrderId] ),
		keepfilters( dimAddress2.IsOverseas = "Y" ),
		keepfilters( dimAddress1.IsOverseas = "Y" )
	)
return
	__ordersWithOverseasAddr1
	+ __ordersWithOverseasAddr2
	- __ordersWithBothAddrOverseas

 

It might not be the simplest but it might be fast and it's easily understandable (if you know math, that is).

 

Best

D

Anonymous
Not applicable

This seems to be working:

 

COUNTROWS(
    FILTER(
            SUMMARIZE(
            'factOrders',
            'factOrders'[OrderID], 
            "IsOverseasOrder",
            MAX
            (
                MAXX('dimAddress1', IF('dimAddress1'[Is Overseas] = "Y", 1, 0)),
                MAXX('dimAddress2', IF('dimAddress2'[Is Overseas] = "Y", 1, 0))
            )
        ),
        [IsOverseasOrder] = 1
    )
)

But it seems far too complicated. Is there a simpler way to do this?

Perhaps:

 

COUNTROWS(
    FILTER(
            SUMMARIZE(
            'factOrders',
            'factOrders'[OrderID], 
            "IsOverseasOrder",
                IF(
                  'dimAddress1'[Is Overseas] = "Y" ||
                    'dimAddress2'[Is Overseas] = "Y",
                  1, 0
                )
            )
        ),
        [IsOverseasOrder] = 1
    )
)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.