0 instead of empty when filtering :grouped by + aggregate count?

Is there any way to filter a list returning zero correctly as 0 and not as nothing?

I need to create a list to give me the count of existing items that fulfill certain conditions (using “filtered” and then “grouped by”). Now that works perfectly if the count >= 1. But if the count is zero it returns no value instead of zero.

e.g.
if the correct results would be: 17, 5, 2 0, 0, 8
using filtered:count I get 17, 5, 2, 8

:confused:

Didn’t find anything yet in the documentation or forum, but still hoping for a facepalm “so easy” solution…

UPDATE: Interestingly the checkbox feature to “not skip empty groups” within :grouped by exists for dates but not for other values. I guess this would be exactly what I need.

1 Like

Thanks for your reply but that does not work as I am using “grouped by”, not the outcome of a a single list.

Using your suggestion I would have to manually loop through a set of such queries which would be a little nightmare (actually a big nightmare).

I have changed the text of the question to be more clear I hope.

What do you with loop through a set of such queries?
Can you use the condition “If empty” change property to 0?

I would not know how to use such condition (if empty) in this context.

Let me explain:
There is a list of Things who have each a list of related Things that have multiple fields each.

I address the list of things with :filtered to extract the elements I need (gives me a list) and then use :grouped by another element + aggregating for count to create the list of counts I need.

Works like a charm but skips zero values like described above.

This might not answer your question for your exact scenario but is tangentially related:

Perhaps you could use the “:defaulting to” feature and enter a value of zero. So, when your filter returns nothing, a text value of 0 will be displayed. I do that for some reports in my app because it looks better than just a blank space.

Yup, thanks Brian. Tangentially related but I fear the core lies within the :grouped by logic where you can’t apply this.

Bump. Anybody any idea?

Turns out numbers offer “do not skip empty” options too. I guess this allows a workaround by adding a number coding to the categorizations used.

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