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
nielsvanleusden
Regular Visitor

Trying to compare to a subquery doesn't work

Hi Guys, first post overhere so excuse me for any mistakes in posting it.


I'm trying to count rows for a custom measure in one of my reports.

It should calculate two filters, one is very simple the second has been breaking my head.

 

In SQL it works fine and looks like this:
SELECT COUNT("id")
FROM "table1"
WHERE "status" = 'x' AND "user" NOT IN (SELECT "userId" FROM table2);

 

It's the bold part that cracks my brain..

How do i get the same result in DAX?


I've already got the part of: Measure = CALCULATE(COUNT('table[id]), '[status] = "x")

Thanks in advance..

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

Hi @nielsvanleusden

 

I am not sure...But give it a shot

 

Could you show some data and expected results?

 

Measure =
CALCULATE (
    COUNT ( Table1[id] ),
    Table1[status] = "x",
    NOT ( CONTAINS ( Table2, Table2[userid], SELECTEDVALUE ( Table1[UserId] ) ) )
)

@Zubair_Muhammad 

 

I think that could work, turns out i've been missing some functions because of the DirectQuery connection.

 

Will try it again a bit later on.

 

Thanks for your reply! 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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.

Top Solution Authors