How do I count the amount of mutual friends between 2 users

I know this is probubly something simple that I’m just stuck on but how do I count the number of friends who are the same between to users?

I am not sure how your data is structured. But say each user has a list of friends and you wanted to see the mutual friends between A and B. You would do a search for users with the condition that the users friend list has to contain A and B. The resulting list would be only users who are friends with both A and B

yes, so you do:

SearchUserA´sFriends intersect SearchUserB´sFriends:count

1 Like

it worked thank you

this is probubly a stupid question but how do I display a list of users who aren’t mutual friends with current user? I’ve been trying to do this in constraints and using minus item but its not working

no such thing as a stupid question but here´s a possible answer. Let´s use colors as example here.

Your app has a table called Colors with the following entries:
Blue
Red
Black
Green
Yellow
White

Your User database has a field called Color (type Color and checked as list) so the users can add their favorite colors to their profile.

Current User has these colors on their Color field:
Blue
Red
Black

And you want to find out what other colors exist in the table Color that the user hasn´t added to their list. The result you are looking for is

Green
Yellow
White

This is how you set up a search to find those 3 colors that aren´t on Current User´s Color. I will be using a text element for this example:

image

In your example, instead of colors, you´re talking about Users that have been added to the Friends List (or whatever you are calling it) but the same logic applies. You want to do a search for all Users or Friends that aren´t on Current User´s Friends List. So set your search constraint as I outlined above.

Here´s an invaluable post for understanding more about searching:

http://forum.bubble.io/t/sql-joins-vs-bubble/25806

Hope this helps