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

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

Reply
Sophie_MGG
Frequent Visitor

Filter on measure in direct query does not work

Hi all,

 

I am trying to create a measure that contains a filter on another measure.

I'm working in direct query mode (unfortunately the data comes in via API so I cannot work via Import mode), so this makes it a bit more complicated. 

 

What I am trying to do is the following: I have a list of orders. Some of them are sent the same day (true,1 ), some not (false, 2).

 

To see true/false I created the following measure:

Measure = CALCULATE(IF('Order'[DLT pick up status]="Order zelfde dag gepickt", true,FALSE()))
Measure 2 = IF([Measure]=TRUE(),1, 0)
 As seen in the screenshot below, this is shown correctly. 
 
Sophie_MGG_2-1642596959363.png

 

Now I want to have another measure, were I calculate all orders (order_number) were measure 2 = 1.
I've tried the following:
 
Measure 3 = CALCULATE(DISTINCTCOUNT('Order'[order_number]),'Order'[Measure 2]=1)
But I get the following error message:
 
Sophie_MGG_1-1642596661628.png

 

I've tried another measure as well, but that outcome sums up to 3, and I expect it to be 2 (2 orders are true), so it seems like the filter is not working.

 

Measure 4 = IF([Measure 2]=1, CALCULATE(DISTINCTCOUNT('Order'[order_number])),BLANK())
 
Can anyone please help? 
 
Many thanks in advance. 
 
Cheers, Sophie
 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Hi @Fowmy 

 

I found a solution. This measure works:


CALCULATE (
DISTINCTCOUNT('Order'[order_number]), FILTER('Order',[DLT pick up status]="Order zelfde dag gepickt")
)
 
(I did not use the filter function before)
 
Many thanks for your help!

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi @Sophie_MGG ,

 

Thanks for your feedback and glad to know your issue has been solved!😀

Please kindly Accept it as the solution to make the thread closed. More people will benefit from it.

 

Eyelyn9_0-1643012025310.png

 

 

Best Regards,
Eyelyn Qin

Fowmy
Super User
Super User

@Sophie_MGG 

Why don't you use a single measure as follows:

 

OrderCountSameDay = 

CALCULATE (
    DISTINCTCOUNT('Order'[order_number]),
    'Order'[DLT pick up status]="Order zelfde dag gepickt"
)

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi @Fowmy ,

 

Thanks for your quick reply. I've tried that as well, but get the same error:

 

Sophie_MGG_0-1642600198108.png

 

Any other ideas? It might not be possible, but in that case I'm wondering why.

 

Cheers,

 

@Sophie_MGG 
Can you re-try, I just modified the measure. Make sure you are creating a measure, not a Column.
Post a picture of the error with formula if you face the this error

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

HI @Fowmy , I am indeed creating a measure, not a column (not possible in DQ mode)..

I've copied the measure from your first post but get the same error:

 

 

Sophie_MGG_0-1642603412757.png

 

Sophie_MGG_1-1642603454348.png

 

Many thanks for all your help. Much appreciated!

 

 

Hi @Fowmy 

 

I found a solution. This measure works:


CALCULATE (
DISTINCTCOUNT('Order'[order_number]), FILTER('Order',[DLT pick up status]="Order zelfde dag gepickt")
)
 
(I did not use the filter function before)
 
Many thanks for your help!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.