Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Mar 13, 2023 11:50 PM
Hi my org does school lessons, we have lessons, teachers (who host the lesson), and our educators (who deliver the lesson). These are spread across 3 tables, with lessons having links to an educator and one or more teachers. I want to calculate the number of unique teachers an educator has reached. So I created a rollup field on the educator that uses COUNTA(ARRAYUNIQUE(values)) on the lesson's teachers. This works great if each lesson only has one teacher. But some lessons have multiple teachers, I tried a workaround using a lookup field and then a formula using ARRAYUNIQUE but that didn't work, as apparently the array formulas are just for rollup operations. Is there a workaround?
Here's an airtable base demonstrating the problem: https://airtable.com/shrSGt3bifbnmwnLp
Solved! Go to Solution.
Mar 14, 2023 09:54 PM
If you've got automations to spare you might want to just:
1. Add a linked field to your "Educators" table to the "Teachers" table
2. Add a lookup field to grab all the teachers this educator has ever interacted with
3. Add an automation that triggers when the lookup field is updated, and pastes the lookup field values into the linked field to the "Teachers" table
This will automatically generate a unique list for you:
I've banged my head against this wall for awhile now and couldn't figure out a formula based solution sorry
> I was trying a rollup with COUNTA(ARRAYUNIQUE(values)) which was giving 4 when it should be 5, but switching it to ARRAYUNIQUE(values) seems to give an accurate list: "Teacher 1, Teacher 2, Teacher 3, Teacher 4, Teacher 5"
One thing to note here is that I think that this might break if you have the following:
Mar 14, 2023 10:56 AM
Airtable can be quirky in lookup fields.
The lookup field with multiple elements (e.g. "Teacher List" in "Educator" in your example base) is in fact a string. It is not an array field any more.
The solution is to use a rollup field instead, and perform the uniqueness filter as part of the rollup setup.
So in table Educators, create a new rollup field (called 'Unique teachers')
- Field in this table: Lessons
- Lesson's table field you want to rollup: Teacher
- Aggregation formula: ARRAYUNIQUE(values)
The resulting field should show unique teachers.
Mar 14, 2023 02:22 PM
Thanks for the reply, I was trying a rollup with COUNTA(ARRAYUNIQUE(values)) which was giving 4 when it should be 5, but switching it to ARRAYUNIQUE(values) seems to give an accurate list: "Teacher 1, Teacher 2, Teacher 3, Teacher 4, Teacher 5"
BUT I want to count the number of teachers, and when I try to use this formula for counting the number of commas, it gives me 2 instead of 5
Mar 14, 2023 09:54 PM
If you've got automations to spare you might want to just:
1. Add a linked field to your "Educators" table to the "Teachers" table
2. Add a lookup field to grab all the teachers this educator has ever interacted with
3. Add an automation that triggers when the lookup field is updated, and pastes the lookup field values into the linked field to the "Teachers" table
This will automatically generate a unique list for you:
I've banged my head against this wall for awhile now and couldn't figure out a formula based solution sorry
> I was trying a rollup with COUNTA(ARRAYUNIQUE(values)) which was giving 4 when it should be 5, but switching it to ARRAYUNIQUE(values) seems to give an accurate list: "Teacher 1, Teacher 2, Teacher 3, Teacher 4, Teacher 5"
One thing to note here is that I think that this might break if you have the following:
Mar 15, 2023 08:01 AM
Thank you so much for looking into it, I too spent an hour trying different formulas because the correct string is RIGHT THERE. But I assume although it's showing "Teacher 1, Teacher 2, Teacher 3, Teacher 4, Teacher 5" it's actually ["Teacher 1", "Teacher 2", "Teacher 3", ["Teacher 4", "Teacher 5"]]. I will try an automation but this has to run on 3000 records so I'm a little nervous about it.
And by that last part do you mean that the COUNTA(ARRAYUNIQUE(values)) breaks if you have multiple teachers per lesson?
Mar 16, 2023 01:49 AM
> I will try an automation but this has to run on 3000 records so I'm a little nervous about it.
Ah, for existing records just copy and paste the values in manually? Click on the "Teacher" lookup field header to select the entire column, copy, paste it into the "Teachers" linked field?
The automations would only be needed for when you create new "Lessons" records
> And by that last part do you mean that the COUNTA(ARRAYUNIQUE(values)) breaks if you have multiple teachers per lesson?
Yeah, I wasn't able to get it to give me the results I expected there
Jul 10, 2024 04:27 AM
I currently use the roll up field with unique array function for that, but that gives me a plain text string with commas.
It is one solution, but it is not visually appealing and not as easily identifiable.
We are a beverage manufacutrer. We make and sell, soda, juice, cider, wine and beer - We separate customers by Alc & non-alc.
I have a SKU source with colour coded categories for each beverage. The intricacies are many here, but all I ask for is a unique option for lookup fields so identifying data is easily visible (category being one of them). I have automations to spare, but it's not a sustainable solution and it makes the base too reliant on me.
Jul 10, 2024 05:40 AM
thank you for the provided solution, but I would like to point out that this (to me) is not a solution but a workaround at best.
If I need to implement this elaborate automation workaround for each instance where I need this solution, I don't feel like I'm practicing no-code no more. I was hoping the airtable team would stay aware of this missing functionality. By marking this question resolved, I'm afraid they consider this problem solved.
Sorry if this sounds like a rant, it probably is.