Forum Discussion
Is it possible to filter a lookup column using a specific criteria?
- Sep 07, 2017
Not a fix for the 5000 items issue, but an alternative to your current solution.
Can I assume that Purchase Orders and Invoices are not being changed ever, when the Purchase Order has status Closed? (I assume that)!
Move all Purchase Orders and Invoices into archive lists - Purchase Order Archive and Invoice Archive - thus keeping your active lists item count lower, hopefully below the limit.
Kind regards
John
You can call it a trick or a hack, but what I have done for filtered lookups is using calculated columns to display what I want in that column.
Say you have a Project list with a Status column and a Title column. The Title column is what you want to filter based on Status. Create a Calculated Title column called Active Projects with a calculation of =IF(Status="Active",[Title],""). This will create blank entries for items that do not have Status=Active.
Then go into your lookup column and point it to "Active Project" and it will not display anything that is blank.
Below is an example I used for displaying only Active Students, same would be for Active Projects or POs or whatever. I use this process that has a source list of 8000+ students with varying degree programs. I create calculated columns to only show students in lookup columns that match the degree criteria for that lookup.
- kateblezJan 09, 2024Copper Contributorthis is genius thank you!
- Stewart TaylorAug 27, 2022Copper ContributorPure genius Scott. This has made my day a lot easier!
- Armin_SimonAug 18, 2020Copper Contributor
May I`m doing something wrong... As soon as I change the status from 'active' to 'inactive', the reports of list with lookup field state 'not assigned' in grouping this field. So link end seems loosing, which is an imaginary behaviour. I am quite new in SPO, is there a way to store the 'ID' of those active records instead of the linked content?
Thanks!
- Victor CliftonApr 17, 2020Copper Contributor
This "hack" of using a calculated column value for the lookup list just made my day!!! Wow, this was so easy. I'm using it to filter a lookup column on a grid view. The normal methods of CAML like I use on the Edit forms don't work in a grid view.
Thank you to the author.
- Beat ZimmermanAug 21, 2019Brass Contributor
Scott Strausbaughexcellent, this did the trick. I was under the impression that calculated columns could not be used for lookup columns in another list, has this changed recently?
Just one minor caveat. How can I avoid the blank records (for each record with 'None') from being displayed at the top of the combo box?
I can move them to the bottom with the following formula, but descending sort order is not desired:
Sort(Choices('Kaizen Championship'.Training_x0020_Batch),Value,Descending)
If I filter for non-blanks, it still shows one blank record at the top, can this be suppressed somehow?
Filter(Choices('Kaizen Championship'.Training_x0020_Batch),Not(IsBlank('Training Batch')))
- Scott StrausbaughAug 21, 2019Iron Contributor
Beat Zimmerman you need to add a ,"" to the end of your calculated column formula. That signifies blank if it doesn't meet the criteria and the drop-down will ignore blanks.
- markm4gFeb 23, 2023Copper Contributor
Scott Strausbaugh my calculated column (PassedStudents) contains this: =IF(Passed=TRUE,[Student Name],"")
When I create a lookup column within the same list, it works as expected. No blanks.
But when I create a lookup in another list, the blanks are there. Any idea what I might be doing wrong?
- Pablo DestefanisFeb 11, 2019Iron Contributor
Thank you for sharing this.
It works fine for lists < 5,000, those with more than 5,000 items will fail even if the number of items in the calculated column is < 5,000.
Hey, Microsoft, I can't help to remind you that 5,000 is not such large number anymore. You are keeping people shackled to a setting that is over A DECADE old!
- Pablo ZaltzMar 16, 2018Copper ContributorHi Scott,
I face the same situation that Fred described.
Thanks for sharing Your simple but powerfull solution.
I will try it soon.
Pablo - Fred YSep 21, 2017Iron ContributorHi, Scott.
I will re-try this out with [] in the formula. I used it earlier as noted above and it still gave me an error when I attempted to use the Calculated column. I was not sure if the JavaScript that I added to pre-assign the lookup value is related to the issue.
In the meantime, I've also explored archiving the Closed items so that ideally the source list will be less than 5,000 items at a time.
Appreciate how you added the screenshots and actual formula.
Fred