Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Using Or function for Slicer selection

Hi everyone,  Im trying to implement OR function in Slicer. Im aware when theres 2 slicers like open and close date, Powerbi filters out using AND function for both slicers. I would like to know if ...
  • v-yueyunzh-msft's avatar
    3 years ago

    Hi , Anonymous 

    According to your description, you want to "Using Or function for Slicer selection" and get the count in the card visual.

    Here are the steps you can refer to :
    (1)This is my test data:

    (2)We need to click "New Table" to create two tables as two slicers and we do not need to create any relationship between tables.

     

    Open SLicer = VALUES('Table'[Open])
    Close Slicer = VALUES('Table'[Close])

     

    (3)Then we need to create two measures like this:

    Flag = var _open_slicer = VALUES('Open SLicer'[Open])
    var _close_slicer = VALUES('Close Slicer'[Close])
    var _cur_open =  MAX('Table'[Open])
    var _cur_close = MAX('Table'[Close])
    return
    IF(OR(_cur_open in _open_slicer , _cur_close in _close_slicer) ,1,-1)
     
    Count = var _t =SUMMARIZE( ALLSELECTED('Table') ,'Table'[ID],'Table'[Open],'Table'[Close], "flag" , [Flag])
    return
    COUNTROWS(FILTER( _t ,[flag] =1))
     
    The [Flag] measure is used to put on the "Filter on this visual" to control which the data need to be displayed.
    The [Count] measure is used to put on the card visual to show the count you need.
     
    (4)Then we put the fields on the visual and we can meet your need:

    If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

    Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

     

    Best Regards,

    Aniya Zhang

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