Need help with :Group by (I think)

Hi all!

Setup: Lunch delivery app

User allergies: All allergies are a type with a value (name of allergy) which the user can choose in a multi choice dropdown to add (up to) multiple allergies to add to their profile.

To get a complete list of how to make a list of users lunch everyday, I need to get a nice short overview of the non-allergic users (just a count with allergies are empty) and allergic users which displays their allergies. If users have the same type of allergy(ies) it should be grouped together to a counted number.

As I have the total number of lunches to make everyday, I need to sort how many of those have tagged allergy for Gluten, Milk and Eggs and how many has only tagged allergy for Egg. I have tried to :group by but I get too many results and my brain is literally farting right now.

Example of what I did:

As you can see there a 4 entries, while I want just 2 because there are just 2 different combinations based on 2 different users. Here the list seems to display more variations of that.

Even when the users have the same 2 types of allergies tagged on them the list shows this:

While I want a list with just “2 (users) ------ Selleri, Sesamfrø” here and not that x 2

Please help… :-S

This topic was automatically closed after 70 days. New replies are no longer allowed.