Forum Discussion

Companyuser101's avatar
2 years ago
Solved

filter with and

Hello, 

 

for the slicer in power bi is an "and" operator possible?

 

So when you select two possibilities on a slicer its always one OR the other. 

Is it possible for a slicer thats its the one AND the other. 

 

 

so for example when I select "FÖSTEN KG" and "GERATECH" I only receive the items with both criterias 

 

Thanks in advance. 

 

 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, Companyuser101 

    First, you can turn on the multi-select feature of Slicer:

    Slicer setting>>Seletion>>Muti_seleted

    In addition, you can use the following DAX to calculate items that belong to the slicer selection:

    sales amount = 
    VAR _silceritem = SELECTCOLUMNS('Table',"product",'Table'[Product])
    RETURN 
    CALCULATE(SUM('Table'[sales]),FILTER('Table','Table'[Product] IN _silceritem))

    This DAX expression mainly uses the seletcolumns function to return the items selected by the slicer, and then uses the IN function to determine whether the current field is in the items selected by the slicer, and if so, then calculate the sales.

    SELECTCOLUMNS function (DAX) - DAX | Microsoft Learn

    The IN operator in DAX - SQLBI

    SELECTCOLUMNS – DAX Guide - SQLBI

    I've provided the PBIX file used this time below.

     

     

     

    How to Get Your Question Answered Quickly

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

    Best Regards

    Jianpeng Li

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

     

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, Companyuser101 

    First, you can turn on the multi-select feature of Slicer:

    Slicer setting>>Seletion>>Muti_seleted

    In addition, you can use the following DAX to calculate items that belong to the slicer selection:

    sales amount = 
    VAR _silceritem = SELECTCOLUMNS('Table',"product",'Table'[Product])
    RETURN 
    CALCULATE(SUM('Table'[sales]),FILTER('Table','Table'[Product] IN _silceritem))

    This DAX expression mainly uses the seletcolumns function to return the items selected by the slicer, and then uses the IN function to determine whether the current field is in the items selected by the slicer, and if so, then calculate the sales.

    SELECTCOLUMNS function (DAX) - DAX | Microsoft Learn

    The IN operator in DAX - SQLBI

    SELECTCOLUMNS – DAX Guide - SQLBI

    I've provided the PBIX file used this time below.

     

     

     

    How to Get Your Question Answered Quickly

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

    Best Regards

    Jianpeng Li

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