Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

How to create custom slicers?

Hello

 

I have the data below:

 

Col1Col2Col3
A1100
A2101
B3102
B4103
B5104

 

I would like to a create custom slicer that will have a tickbox named 'Top 3' and when you click that, it will filter to the largest three records based on Col2 and a tickbox named 'Bottom 3' to select the smallest (complying with any additional filters of course).

 

How can I do that?

 

Thanks!

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) We can create a table.

     

    tickbox = {"Top3","Buttom3"}

     

    (2) We can create a measure. 

     

    Flag =
    var _selectedvalue=SELECTEDVALUE(tickbox[Value])
    var _topn=SELECTCOLUMNS(TOPN(3,ALLSELECTED('Table'),'Table'[Col2],ASC),"1",'Table'[Col3])
    var _buttom=SELECTCOLUMNS(TOPN(3,ALLSELECTED('Table'),'Table'[Col2],DESC),"1",'Table'[Col3])
    return
    SWITCH(    _selectedvalue,    
    "Top3",IF(MAX('Table'[Col3]) in _topn,1,0),    
    "Button3",IF(MAX('Table'[Col3]) in _buttom,1,0),    
    1)

     

    (3) As shown in the following image, set up filtering on visuals and then the result is as follows.

    Best Regards,

    Neeko Tang

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

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) We can create a table.

     

    tickbox = {"Top3","Buttom3"}

     

    (2) We can create a measure. 

     

    Flag =
    var _selectedvalue=SELECTEDVALUE(tickbox[Value])
    var _topn=SELECTCOLUMNS(TOPN(3,ALLSELECTED('Table'),'Table'[Col2],ASC),"1",'Table'[Col3])
    var _buttom=SELECTCOLUMNS(TOPN(3,ALLSELECTED('Table'),'Table'[Col2],DESC),"1",'Table'[Col3])
    return
    SWITCH(    _selectedvalue,    
    "Top3",IF(MAX('Table'[Col3]) in _topn,1,0),    
    "Button3",IF(MAX('Table'[Col3]) in _buttom,1,0),    
    1)

     

    (3) As shown in the following image, set up filtering on visuals and then the result is as follows.

    Best Regards,

    Neeko Tang

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