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
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] ) ) )
)

Regards
Zubair

Please try my custom visuals

@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
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.