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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
akhaliq7
Continued Contributor
Continued Contributor

Filter Function multiple filters

I want to use a filter function In a calculate function with multiple filters how can I write this

 

CALCULATE(
    [Sales],

    KEEPFILTERS(

        FILTER(

        ALL('DimDate'),

        DimDate[Date] > Date(2024,1,1)

        -- want to add another filter below this for date is less than the end of January 

        )

    )

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

Hi @akhaliq7 ,

Based on your problems, I think you can use the logical operators && (AND) or || (OR) to combine conditions.

Here's what I have done with your DAX code.

CALCULATE(
    [Sales],

    KEEPFILTERS(
        FILTER(
            ALL('DimDate'),
            DimDate[Date] > Date(2024, 1, 1) &&
            DimDate[Date] < Date(2024, 2, 1)
        )
    )
)

 

 

 

Best Regards

Yilong Zhou

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

2 REPLIES 2
v-yilong-msft
Community Support
Community Support

Hi @akhaliq7 ,

Based on your problems, I think you can use the logical operators && (AND) or || (OR) to combine conditions.

Here's what I have done with your DAX code.

CALCULATE(
    [Sales],

    KEEPFILTERS(
        FILTER(
            ALL('DimDate'),
            DimDate[Date] > Date(2024, 1, 1) &&
            DimDate[Date] < Date(2024, 2, 1)
        )
    )
)

 

 

 

Best Regards

Yilong Zhou

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

I am using the below as well what is more efficient?

CALCULATE(

    [Sales],

    KEEPFILTERS(DimDate[Date] > Date(2024, 1, 1)),
    KEEPFILTER(DimDate[Date] < Date(2024, 2, 1))

)

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.