Forum Discussion

AlexisPREVOT's avatar
AlexisPREVOT
Resolver I
5 years ago
Solved

Excluding multiple rows with one filter

Hello,

I just created a measure and a slicer that allows me to exclude items that I don't want.
For example :

My initial table :                 

    

 

 

My filtered table  if I want to exclude ID Article = 1 :

 

 

The DAX Code associated is : 

VAR d =
LOOKUPVALUE('ARTICLE'[ID ARTICLE], 'ARTICLE'[ID ARTICLE], MIN('Table ARTICLE'[ID ARTICLE]))

RETURN
IF (
ISFILTERED (Table ARTICLE'[ID ARTICLE]),
IF ( d IN VALUES ('ARTICLE'[ID ARTICLE]), 1, 0 ),
0
)


But I want to go further by "deleting" the visualization of the table all the companies that have an ID Article = 1

So my end result should be:

 

 

Please do you have an idea of ​​the filter that I have to put in place to achieve this result?
Thanks in advance.

 

Alexis 

  • Hi, AlexisPREVOT 

     

    Why not just create a slicer for the ID field.

    If you insist on using a measure, try creating the following measures:

    _exclude = 1
    _Flag =
    IF ( 'Table'[_exclude] = MAX ( 'Table'[ID Article] ), 0, 1 )
    

    Or the whatif parameter will work just as well

    _Whatif flag = 
        IF('exclude items'[exclude items Value] = MAX('Table'[ID Article]),0,1)

    There are many ways to achieve the result you want, choose the one you like

    result:

    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.

5 Replies

  • AlexisPREVOT you have few ways to solve this, one is to add a column in your table and then use this column where value = 0

     

    ID to Filter = 
    CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[ID Enterprise] ), 'Table'[ID Article] = 1 ) + 0

     

    Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

  • Hi, AlexisPREVOT 

     

    Why not just create a slicer for the ID field.

    If you insist on using a measure, try creating the following measures:

    _exclude = 1
    _Flag =
    IF ( 'Table'[_exclude] = MAX ( 'Table'[ID Article] ), 0, 1 )
    

    Or the whatif parameter will work just as well

    _Whatif flag = 
        IF('exclude items'[exclude items Value] = MAX('Table'[ID Article]),0,1)

    There are many ways to achieve the result you want, choose the one you like

    result:

    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.

  • Hi parry2k ,

     

    I just tested and it works if i force the value 'Table'[ID Article] = 1 to a given value.

    It is true that I misspoke my request but I would like the "1" to be automaticly replaced by the value of my slicer.

     

    It is possible ?

  • Hi v-angzheng-msft ,

     

    Sorry for the delay of my response.

    Thank you for your solution which fully answered my request.

     

    Have a good day.

     

    Alexis