Counting the frequency of an element in a list?

Is there a way to count how frequent an element in a list shows up?

For example if L=[ 1, 1, 1, 1, 1, 1, 3] and asked how many 1’s showed up, it would give me 6.

Thanks for any help!

https://www.desmos.com/calculator/ninnulcf2j

If you’re wanting to do it in the CL in Activity Builder, you do something like:

List = [1, 1, 1, 1, 1, 1, 3]

num = 1

count = List.reduce(0, (acc,curr) => when curr = num numericValue(`${acc}+1`) otherwise acc)

What’s the 0 in List.reduce(0, (acc,curr)? Is that the index of the list? I believe it is list.function(index, element), so maybe I just answered my own question.

For what I need right now I just need it in the graph. But this is really helpful!

This is great! Thanks!

For most list functions, it’s list.function(element, index). For reduce, it’s list.reduce(starting value, (accumulator value, current value, current index).