Counting number of times something appears in list

Hello,

I have a football score app for amateur football.

I have a dataset for matches, in that dataset I have goal scorers. I want to be able to count how many goals a certain player has scored across a season by adding up how many times they have appeared on the goal scorer list.

Its easy to count how many times they have appeared in the list. For example, if they score 1 goal in 3 games, it will calculate the number 1, but if he scored 3 goals in the first game, 1 in the second game and 0 in the 3rd game, it will say “2” (as he has scored in 2 of teh games) I want it to say 4 as it will add up all the times he has appeared. Any ideas?

1 Like

Hi there, @mike1… how are you tracking multiple goals scored by a player in a game? It sounds like you are counting matches in which a player scored instead of counting goals. It should be pretty easy to get the goal count/sum, but without knowing more about your setup, it’s hard to be more specific.

Best…
Mike

So it goes into a list within the data set. The player will go in there twice. See attahced.

I made a quick example that counts the goals for the current user across any match in which they scored. The expression starts with a search for the appropriate matches.

Then, an advanced filter is used to get to the count.

1 Like

Thank Mike…

I am trying to get it to work on a repeating group so I am not looking at just the current user. I am going to try other thiings and let you know if I come up with a solution. Thank you.

Yup, I was pretty sure you wanted a repeating group, but I thought what I gave you might help you get there.

For a repeating group, you could set the type of content to User and set the data source to Search for Matches:each item's goal scorers:unique elements. Then, have a text element in the repeating group that displays the current cell’s user’s name, and finally, while I don’t love doing searches within elements in repeating groups, have another text element that has the expression I showed in my screenshots minus the constraint on the search for matches and changing Current User in the advanced filter to Current cell's User.

Anyway, that’s one way to go, and I will see myself out of this thread now. Best of luck!

1 Like