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

Nesting AND and OR in FILTER

I need to nest an AND and an OR clause in a FILTER, but I can't figure out how to do it.

 

 

Count of subcontracts in process = CALCULATE( COUNTROWS( subcontracts )
      , FILTER( VALUES( subcontracts[subcontract_begin_date] )
                ,  subcontracts[subcontract_begin_date]  <  max(CalendarAwardStartDate[date] )
      )
      , FILTER( values(subcontracts[execution_date])
                ,subcontracts[execution_date]>max(CalendarAwardStartDate[Date]) || (isblank(subcontracts[execution_date]) && subcontracts[status]="Fully executed")
      )
)

 

 

When I try this, the subcontracts[status] field gives me a red squiggly underline. Is this a context issue or something else?

 

Thanks!

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

Hi @kman42 ,

 

Please refer to the following measure:

Count of subcontracts in process =
CALCULATE (
    COUNTROWS ( subcontracts ),
    FILTER (
        VALUES ( subcontracts[subcontract_begin_date] ),
        AND (
            subcontracts[subcontract_begin_date] < MAX ( CalendarAwardStartDate[date] ),
            OR (
                subcontracts[execution_date] > MAX ( CalendarAwardStartDate[Date] ),
                AND (
                    ISBLANK ( subcontracts[execution_date] ),
                    subcontracts[status] = "Fully executed"
                )
            )
        )
    )
)

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

2 REPLIES 2
v-deddai1-msft
Community Support
Community Support

Hi @kman42 ,

 

Please refer to the following measure:

Count of subcontracts in process =
CALCULATE (
    COUNTROWS ( subcontracts ),
    FILTER (
        VALUES ( subcontracts[subcontract_begin_date] ),
        AND (
            subcontracts[subcontract_begin_date] < MAX ( CalendarAwardStartDate[date] ),
            OR (
                subcontracts[execution_date] > MAX ( CalendarAwardStartDate[Date] ),
                AND (
                    ISBLANK ( subcontracts[execution_date] ),
                    subcontracts[status] = "Fully executed"
                )
            )
        )
    )
)

 

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

 

Best Regards,

Dedmon Dai

jdbuchanan71
Super User
Super User

I think you might have just had a ) in the wrong spot, does this work for you?

Count of subcontracts in process =
CALCULATE (
    COUNTROWS ( subcontracts ),
    FILTER (
        VALUES ( subcontracts[subcontract_begin_date] ),
        subcontracts[subcontract_begin_date] < MAX ( CalendarAwardStartDate[date] )
    ),
    FILTER (
        VALUES ( subcontracts[execution_date] ),
        ( subcontracts[execution_date] > MAX ( CalendarAwardStartDate[Date] ) || ISBLANK ( subcontracts[execution_date] ) )
        && subcontracts[status] = "Fully executed"
    )
)

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.