Here we see that User1 has 2 meaningful answers (yes/know) to questions Q1 and Q2. So we need to count exactly the same answers - which means the same answer to the same question Q1=Yes, Q2=No)
[quote=“patricia, post:3, topic:84636”]
Do you mean Current User is an Admin or something so they can see all other users identities? Or can users see each other’s identities and answers?
[/quote] - yes, it’s the current user. So the thing should work for any Current User.
So if User1 is logged in (Current User) the result should be:
User2 1 (number of the same answers - only to Q1 in this case)
Ok. I’ll get my paper and pencil out in about an hour and come back to you with a solution, if nobody else get’s to it first. I’m busy on something else just now.
Are you familiar with the :Group By in RGs? If Yes then I think your answer might lie in that. I would need to experiment a little myself to be sure but I think it might be something like: Text User Name: Do a Search for UserAnswers:group by User with constraints to do the count of same answers.
I know that is not very helpful but it’s just meant for thought until I find time to dive in
Yup, I am familiar with Group By and was playing with it too.
By Intersecting UserAnswers (user <> Current User) with Current User’s UserAnswers (user = Current User) we can get only the questions that were responded by the Current User… Then we need to group it some how, but… here we are =)
Sorry. It has been one of days. If my brain can’t find the answer tonight I’ll do it first thing in the morning. I think the Group By is not going to do everything you need in one go so let’s chat out a sequence of steps which might be messy, then see if they work, and then if we can improve the approach.
The outer group is user so we need to have an RG with Data Source Do a Search for user. The cell should have Text = Current Cell’s User’s Name and then a count of matching or intersecting answers.
Next we need to work out how to get the count. Therein lies the problem so here’s how I think we can do it, sounds inefficient but right now I can’t see an alternative.
Create a field in UserAnswers called TextAnswers and make it a list of Texts
When a user answers a question add the letter Q: followed by question number and A: followed by answer so it would read like this “Q:1 A:yes, Q:2 A:no, etc. Order won’t matter so you can add and remove when users answer in the wrong order or change their mind.
Now we need the match count. So you need to make the Text Element displaying count in RG cell in (1) above = Current Cell’ User’s TextAnswers :intersect with Current User’s TextAnswers :count
It is not exactly right but I believe something very close to what you need once you apply it to your data structure. I probably don’t have the data references accurate but you are more than capable of sorting that. Try building it and shout if you hit a problem. I’m finishing for today but I’ll be around over the weekend and will check in to the forum.
The post title confused me too @magnus.kanholt but when reading your reply something clicked and I realised the “kinda” probably meant the request was vanilla bubble. So your input helped put me in the right track whether you realised it or not. I should be thanking you.
No I don’t actually but I have a 30 year old computer scientist qualification so I’m very analytical and I can’t resist a challenge. Once I’m clear about what I want to achieve I’ll find the way. I did no Development for 25 years then found Bubble and over the past two years I’ve done at most 6 months full-time, probably not even that. It’s the first time I ever enjoyed the development process. In the past I always preferred UX/UI and Product/Project management.
So as Patricia suggested now I have an ‘AnswerCode’ field in UserAnswers which is ‘QuestionBody’+’’ (‘yes’ for example).
So I have a repeating group of all users with a Text1 = User.Name and Text2 = Count (intersection based on UserAnswer.AnswerCode). It works. So I have smth like (if logged as User1):
User2: 1
User3: 2
User5: 5
But actually I need to find the user with the highest number (without any RG - just need this top user).
I’m assuming you will be displaying in a Text as that is not clear. Could you use the same formula As above with a few additions to find the top match?
If in an RG even if it only were to show one entry, you might be able to use as similar formula as before to display the User i.e. Current Cell’ User’s TextAnswers :intersect with Current User’s TextAnswers :count:max:first item’s User (I don’t remember the exact syntax but I think something like that is possible). If this is something you only want to do once then a 1x1 RG is probably best.
If this is something you need to do often then you probably need to create another Match data table with fields First User, Second User, U1 Match Text string, U2 Match Text string, Match Score, so a record to compare every question for every two user pairing. You could store your Match Text in this table instead of the existing tables you have them in. Again it appears this approach is duplication but it would make everything you have been trying easier on you. Personally I would stick the Save Answer Workflow into a back-end API that builds the match strings and updates the relevant data tables in the background so the app remains snappy in use.
Hope you can get an idea to move you forward from this soliloquy.
Still looking for the best solution…
Yes we can have Matches between all users with a score of same answers, update them as users answers questions etc, but it’s too much for DB. instead it makes sense to store only highest matches.
So what I would need is:
Datatype User Answers:
User1, Text Answer (which is a combination of a Question Id + user’s answer, for example ‘Y’).
Data:
User1 Q1Y
User1 Q2N
User1 Q3Y
User2 Q1N
User2 Q2N
User2 Q3N
User3 Q1Y
User3 Q1Y
User3 Q3Y
For the current user (User1) I need to find the user who has the maximum number of the same answers (which is User3 who has 2 same answers (User2 has 1)).
I need just this one user. Preferably with one select statement. Probably it will be running in Backend Workflows and a result of it should just one Match created.
If you are prepared to give me view access to your editor, with instructions for where I should look, I will jump in tomorrow and take as look. Next time insert @patricia then I will receive an email. I was not on the forum so had not seen your follow up. Almost didn’t see it today.