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
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
v-eqin-msft
Community Support
Community Support

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