I need to return a lookup on a table once a slicer has been selected.

RockandGrohl

Well-known Member
Joined
Aug 1, 2018
Messages
801
Office Version
  1. 365
Platform
  1. Windows
Hi guys, two ways to look at a solution to this problem.

I have a scatter chart on a sheet called Curves, and the data for this chart is held on a sheet called Database. I have loaded up about 6 slicers for Database which are located on Curves. The user can select slicers in sequence to filter the data through different levels. Think of it like "Groceries > Fruit > Apple > Green > Granny Smith" or something like that

What I want to do is return a lookup once the last level is triggered. This slicer is called Asset as it pertains to the Asset column on the Database. I want a lookup to then use the Asset as the lookup value, against the Database table and return the result in the column called "Primary UoM". In the above example, once "Granny Smith" is selected it would return "Weight (g)" for instance.

I'm trying to think of a way to do it and have been spending all morning prompting ChatGPT but it's giving me fairly by-the-numbers solutions that involve basically checking the worksheet every time a change or calculation is made.

In my head, an ideal solution would be for a macro to detect column G (Asset) has been filtered in the Database tab, in which case the Primary UoM's will all be the same, and therefore just return the Primary UoM (column P) of the first visible row.

This doesn't seem to be possible, however, and therefore I'm left stuck. ChatGPT's solution could work, but looking at the code it looks incredibly fragile and I think functionality would stop as it requires EnableEvents etc, which I've found to be quite temperamental in the past.


Any ideas would be appreciated!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Not sure about what you want, and I don't care for macros. I made up a table with a helper column and when there is only one item left after filtering, it shows the something. You can make it only show the first one using "TAKE" instead.
MrExcelPlayground23.xlsx
NOPQR
6ItemCharacteristicSecondWeight (g)Visible?
7FoodFruitApple501
8FoodFruitPear401
9FoodMeatSteak2501
10FoodMeatChop Meat2501
11ClothesShirtGood Shirt1
12ClothesShirtBad Shirt1
13ClothesPantsGrey Pants1
14GamesBoardMonopoly1
15GamesSportBaseball Bat1
16
17
18 
Sheet5
Cell Formulas
RangeFormula
R7:R15R7=AGGREGATE(3,5,[@Item])
P18P18=LET(a,FILTER(Table6[Weight (g)],Table6[Visible?]),IF(ROWS(a)=1,a,""))


1717072075690.png
 
Upvote 0
Not sure about what you want, and I don't care for macros. I made up a table with a helper column and when there is only one item left after filtering, it shows the something. You can make it only show the first one using "TAKE" instead.
MrExcelPlayground23.xlsx
NOPQR
6ItemCharacteristicSecondWeight (g)Visible?
7FoodFruitApple501
8FoodFruitPear401
9FoodMeatSteak2501
10FoodMeatChop Meat2501
11ClothesShirtGood Shirt1
12ClothesShirtBad Shirt1
13ClothesPantsGrey Pants1
14GamesBoardMonopoly1
15GamesSportBaseball Bat1
16
17
18 
Sheet5
Cell Formulas
RangeFormula
R7:R15R7=AGGREGATE(3,5,[@Item])
P18P18=LET(a,FILTER(Table6[Weight (g)],Table6[Visible?]),IF(ROWS(a)=1,a,""))


View attachment 112080
I feel like this is the right track.

When the column with "Granny Smith" gets filtered, there will actually be numerous rows, but I'm only interested in getting the lookup working on the first visible row. Would your method be able to do that?
 
Upvote 0
In P18 of my example, if you put in:

Excel Formula:
=TAKE(FILTER(Table6[Weight (g)],Table6[Visible?]),1)

That will just take the top row of whatever the filtered (or unfiltered) table shows.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,191
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top