How to capture the selected value of a slicer in a formula?

Copper Contributor

I need to capture the selected value of a slicer like ID or Date. In browsing the Slicer Settings, there a defined name for the Slicer and stated that its can be used in a formula. I tried to in insert in a cell =INDERECT formula or simply =defined name but none did work. 

Is there a way to get the value of selected slicer?

 

Thamer_Tarabzouni_0-1665459194896.png

 

6 Replies

@Thamer_Tarabzouni The attached article clearly demonstrates how to do just that. And at the end it also explains the real meaning of the bit "Name to use in formulas:"

https://www.myonlinetraininghub.com/use-excel-slicer-selection-in-formulas 

@Thamer_Tarabzouni 

Alternatively if you run Excel > 2010 on Windows, load your SourceTable to the Data Model (Power Pivot):

 

_Screenshot.png

 

in I11 (returns the 1st item selected in Slicer_Name:(

=CUBERANKEDMEMBER("ThisWorkbookDataModel",
    CUBESET("ThisWorkbookDataModel", Slicer_Name),
    1
)

 Corresponding sample attached

@L z. 

And if on 365 to return multiple selections

slicerSelection=
LAMBDA( connection, slicer,
LET(
    itemsSelected, CUBESETCOUNT( CUBESET(connection, slicer) ), 
    CUBERANKEDMEMBER(connection,slicer, SEQUENCE( itemsSelected )))
);

called as

=slicerSelection("ThisWorkbookDataModel", Slicer_Name)

image.png

 

hi @L z. , I just want to ask if you know how to solve the duplicated value that is not displaying in pivot table just like in the photos. Even if I click in the slicer, duplicated value will just show 1 result. please help. Thank you.

001.PNG002.PNG 

@banderasxp 

You're asking for a PivotTable to not behave as a PivotTable (what's the point???)

 

If you run Excel > 2013 / Windows you can do it though:
- Load the Pivot Source table to Power Query
- Add an ID (Index) column
- Build the PivotTable from the query
- Add the ID column to the Rows area of the PivotTable
- Hide the column that holds the [ID] field

 

Sample.png

Sample attached

wow, thank you, so my problem is I don't have an Id for each person. Thank you so much, God bless❤