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
gpiero
Skilled Sharer
Skilled Sharer

How to include more FILTER() in a DAX formula

 

I have the following measure that works properly.

 

NoDelivPGDistrDPL =
CALCULATE (
    COUNTAX ( ZCSDLV; ZCSDLV[c1] );
    DISTINCT ( ZCSDLV[c1] );
    FILTER ( ZCSDLV; ZCSDLV[Cod1] = "149" );
    FILTER ( ZCSDLV; ZCSDLV[Org1] = "MDCS" );
    FILTER ( ZCSDLV; ZCSDLV[Pae1] = "CN" )
    )

 

Now I need to include other FILTER() as showed below but it returns an empty value

 

NoDelivPGDistrDPL =
CALCULATE (
    COUNTAX ( ZCSDLV; ZCSDLV[C1] );
    DISTINCT ( ZCSDLV[C1] );
    FILTER ( ZCSDLV; ZCSDLV[Cod1] = "149" );
    FILTER ( ZCSDLV; ZCSDLV[Org1] = "MDCS" );
    FILTER ( ZCSDLV; ZCSDLV[Pae1] = "CN" );
    FILTER ( ZCSDLV; ZCSDLV[Pae1] = "MX" );
    FILTER ( ZCSDLV; ZCSDLV[Pae1] = "AR" );
    FILTER ( ZCSDLV; ZCSDLV[Pae1] = "RU" )
)

I tried to use COUNTROWS instead of COUNTAX  and filtering "CN" "MX" "AR" "RU" before [cod1] and [Org1] and I got always an empty values.

 

 

I know it should be easy but I did not understand how to apply a multiple filter in this case.

 

Could you kindly indicate to me where is the mistake'

 

Thanks a lot

If I can...
1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

This should work...

 

NoDelivPGDistrDPL =
CALCULATE (
    COUNTAX ( ZCSDLV; ZCSDLV[C1] );
    DISTINCT ( ZCSDLV[C1] );
    FILTER ( ZCSDLV; ZCSDLV[Cod1] = "149" );
    FILTER ( ZCSDLV; ZCSDLV[Org1] = "MDCS" );
    FILTER (
        ZCSDLV;
        ZCSDLV[Pae1] = "CN"
            || ZCSDLV[Pae1] = "MX"
            || ZCSDLV[Pae1] = "AR"
            || ZCSDLV[Pae1] = "RU"
    )
)

This should actually give you same as above...

 

NoDelivPGDistrDPL =
CALCULATE (
    DISTINCTCOUNT ( ZCSDLV[C1] );
    FILTER ( ZCSDLV; ZCSDLV[Cod1] = "149" );
    FILTER ( ZCSDLV; ZCSDLV[Org1] = "MDCS" );
    FILTER (
        ZCSDLV;
        ZCSDLV[Pae1] = "CN"
            || ZCSDLV[Pae1] = "MX"
            || ZCSDLV[Pae1] = "AR"
            || ZCSDLV[Pae1] = "RU"
    )
)

 But I would actually simplify even further like this...

 

NoDelivPGDistrDPL =
CALCULATE (
    DISTINCTCOUNT ( ZCSDLV[C1] );
    FILTER (
        ZCSDLV;
        ZCSDLV[Cod1] = "149"
            && ZCSDLV[Org1] = "MDCS"
            && ( ZCSDLV[Pae1] = "CN"
            || ZCSDLV[Pae1] = "MX"
            || ZCSDLV[Pae1] = "AR"
            || ZCSDLV[Pae1] = "RU" )
    )
)

Hope this helps! Smiley Happy

View solution in original post

2 REPLIES 2
Sean
Community Champion
Community Champion

This should work...

 

NoDelivPGDistrDPL =
CALCULATE (
    COUNTAX ( ZCSDLV; ZCSDLV[C1] );
    DISTINCT ( ZCSDLV[C1] );
    FILTER ( ZCSDLV; ZCSDLV[Cod1] = "149" );
    FILTER ( ZCSDLV; ZCSDLV[Org1] = "MDCS" );
    FILTER (
        ZCSDLV;
        ZCSDLV[Pae1] = "CN"
            || ZCSDLV[Pae1] = "MX"
            || ZCSDLV[Pae1] = "AR"
            || ZCSDLV[Pae1] = "RU"
    )
)

This should actually give you same as above...

 

NoDelivPGDistrDPL =
CALCULATE (
    DISTINCTCOUNT ( ZCSDLV[C1] );
    FILTER ( ZCSDLV; ZCSDLV[Cod1] = "149" );
    FILTER ( ZCSDLV; ZCSDLV[Org1] = "MDCS" );
    FILTER (
        ZCSDLV;
        ZCSDLV[Pae1] = "CN"
            || ZCSDLV[Pae1] = "MX"
            || ZCSDLV[Pae1] = "AR"
            || ZCSDLV[Pae1] = "RU"
    )
)

 But I would actually simplify even further like this...

 

NoDelivPGDistrDPL =
CALCULATE (
    DISTINCTCOUNT ( ZCSDLV[C1] );
    FILTER (
        ZCSDLV;
        ZCSDLV[Cod1] = "149"
            && ZCSDLV[Org1] = "MDCS"
            && ( ZCSDLV[Pae1] = "CN"
            || ZCSDLV[Pae1] = "MX"
            || ZCSDLV[Pae1] = "AR"
            || ZCSDLV[Pae1] = "RU" )
    )
)

Hope this helps! Smiley Happy

@Sean

Thank you, it works

gpiero

If I can...

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.