# Get the difference in users between two fields

**URL:** <https://community.fibery.io/t/get-the-difference-in-users-between-two-fields/4622>\
**Category:** Get Help\
**Created:** [June 14, 2023, 5:20am UTC](https://community.fibery.io/t/get-the-difference-in-users-between-two-fields/4622 "2023-06-14T05:20:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nvee](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/nvee/32/6860_2.png) [@nvee](https://community.fibery.io/u/nvee)\
**Post date:** [June 14, 2023, 5:20am UTC](https://community.fibery.io/t/get-the-difference-in-users-between-two-fields/4622/1 "2023-06-14T05:20:31Z")

</div>

I have 2 databases in a space, Sessions and Inventory. Each one has assignees. Sessions have one Inventory, and Inventory has many Sessions.

I created a lookup column on Inventory to show all Session users for an entry. Now I’d like to create a new column which shows all users from Inventory assignees, which are NOT in the Session assignees.

I’m basically wanting a column to see which users have not been allocated to a session for a particular Inventory. Is there a way to do this with formulas? Or would I need to create a rule and do this with Javascript?

---

<div class="post-metadata">

**Author:** ![ccollins](https://avatars.discourse-cdn.com/v4/letter/c/bbe5ce/32.png) [@ccollins](https://community.fibery.io/u/ccollins)\
**Post date:** [June 14, 2023, 11:59am UTC](https://community.fibery.io/t/get-the-difference-in-users-between-two-fields/4622/2 "2023-06-14T11:59:21Z")

</div>

Relevant, might help:

> [@Generating an user list by subtracting other users lists](https://community.fibery.io/t/generating-an-user-list-by-subtracting-other-users-lists/4503):
>
> I need help with a formula for a button: I have 4 relation to users field in my meetings: Expected, Present, Informed absent and Non-informed absent. For the expected I already have a button that generate the list of expected people. Presents I usually add manually, so as Informed absent. Now I wanted to create a Generate Non-Informed Absent List that would take the Expected users list, subtract the presents and the informed absents and get to a result of Non-informed absent. For example, use…

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [June 14, 2023, 2:47pm UTC](https://community.fibery.io/t/get-the-difference-in-users-between-two-fields/4622/3 "2023-06-14T14:47:44Z")

</div>

Related:

> [@How to union two list fields in the same Database?](https://community.fibery.io/t/how-to-union-two-list-fields-in-the-same-database/2467/25):
>
> Can you provide some example use cases that need intersect or diff. It’s always interesting to hear what people want to achieve.

---

<div class="post-metadata">

**Author:** ![nvee](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/nvee/32/6860_2.png) [@nvee](https://community.fibery.io/u/nvee)\
**Post date:** [June 14, 2023, 9:31pm UTC](https://community.fibery.io/t/get-the-difference-in-users-between-two-fields/4622/4 "2023-06-14T21:31:49Z")

</div>

Thanks for all the help. I ended up using a script with the following (I changed Inventory to Available Hours):

```auto
// Developer reference is at api.fibery.io/#action-buttons

// Fibery API is used to retrieve and update entities
const fibery = context.getService('fibery');

for (const ent0 of args.currentEntities) {
    const availableHourEntity = await fibery.getEntityById('Sessions/Available Hour', ent0['Available Hours'].Id, ['Available', 'Id', 'Assignees', 'Booked Sessions'])

    if (availableHourEntity) {
        const sessions = await Promise.all(availableHourEntity['Booked Sessions'].map(session => fibery.getEntityById('Sessions/Session', session.Id, ['Assignees'])))

        const assignedIds = sessions.reduce((prev, session) => {
            const ids = session.Assignees.map(s => s.Id)
            return [...prev, ...ids];
        }, [])

        const availableUsers = availableHourEntity.Assignees.filter(user => !assignedIds.includes(user.Id))

        // First remove all available users
        await Promise.all(availableHourEntity.Available.map(user => fibery.removeCollectionItem('Sessions/Available Hour', availableHourEntity.Id, 'Available', user.Id)))

        // Then reassign available users
        await Promise.all(availableUsers.map(user => fibery.addCollectionItem('Sessions/Available Hour', availableHourEntity.Id, 'Available', user.Id)))
    }
}

```

Then I’ve just assigned that to the entity attach and detach on the Session and Available Hour.

---

<div class="post-metadata">

**Author:** ![Mircea\_Braescu](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/mircea_braescu/32/9729_2.png) [@Mircea\_Braescu](https://community.fibery.io/u/Mircea_Braescu)\
**Post date:** [June 11, 2025, 12:06pm UTC](https://community.fibery.io/t/get-the-difference-in-users-between-two-fields/4622/5 "2025-06-11T12:06:51Z")

</div>

Same need as OP.  
We have Sharing Wednesday meetings where we enter the attendees.  
We have a SW Feedback database where each team member can provide feedback for that meeting.  
We know who attended, we know who provided feedback, I want a list of who is pending.

I solved this with workarounds by converting the names to strings and processing them as such, but it’s not a very elegant solution
