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
Peter_2020
Helper III
Helper III

Filter with specific definition

Hi all, 

I would like to ask you for help with DAX formula for following situation:

I have this simple table with 2 columns where is order number and operation number:

ORDEROPERATION
1111
1112
2221
3331
3332
3333
3334

And I need to have the list of all orders with note if the specific order contains operation 2 and 4. So expected outcome will looks like this:

ORDERMEASURE
1110
2220
3331

0 means that order doesn´t contain operation 2 and 4 and 1 means that order contains operation 2 and 4.

 

Any idea how to do it?

Thanks.

P. 

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @Peter_2020 

 

Try to create a measure like this:

Measure = 
VAR _OR_OP=SUMMARIZE(FILTER(ALL('Table'),'Table'[ORDER]=MAX('Table'[ORDER])),[OPERATION])
VAR _IF=
    IF( {2} IN _OR_OP&&{4} IN _OR_OP
        ,1,0
        )

RETURN _IF

Result:

vangzhengmsft_0-1636950094251.png

 

Please refer to the attachment below for details. Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-angzheng-msft
Community Support
Community Support

Hi, @Peter_2020 

 

Try to create a measure like this:

Measure = 
VAR _OR_OP=SUMMARIZE(FILTER(ALL('Table'),'Table'[ORDER]=MAX('Table'[ORDER])),[OPERATION])
VAR _IF=
    IF( {2} IN _OR_OP&&{4} IN _OR_OP
        ,1,0
        )

RETURN _IF

Result:

vangzhengmsft_0-1636950094251.png

 

Please refer to the attachment below for details. Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-angzheng-msft Thanks a lot! it works!

amitchandak
Super User
Super User

@Peter_2020 , Measure like

 

Countx(Summarize(Table, Table[Opearation], "_1",calculate(distinctcount(Table[Operation]) , filter(Table, Table[Operation] in {2,4}  ))) , if( [_1]=2,1,0) )

@amitchandak Thanks for the tip but the result is for all orders the same - value 1....

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.