Can't get Distinct option to work on Codeless Get Object Count

Hi,

I am trying to use the Codeless “Get Object Count” block on a view.
Because I want to return the number of distinct rows, I set the distinct option to true.
Although I clearly have rows which differ, I systematically get a result of 1.
Is this to be expected ?
If so, how can I return the number of distinct rows without having to feed them all to the client side, which defeats the purpose ?

Thank you for your help.

Nicolas

Hi Nicolas,

It appears the distinct option doesn’t work with Views. I recommend creating a separate view where you group the records by the column you expect unique values in and then getting the count for that view.

Regards,
Mark

Hi Mark and thanks for the quick reply.

I have tried that. However, it looks as though aggregation can only be performed on the data pertaining to a single constituent table of the view. However, the whole point of building the view in my case was being able to group by across more than one table. I am used to doing this in SQL so I know it is possible, but I haven’t been able to replicate this behavior in Backendless. Could you advise ?

Best regards,
Nicolas

You can aggregate across multiple tables. In fact, you can aggregate data in a related column if needed.

It is hard for me to advise without knowing the specifics. Without them, this becomes an academic exercise, which is not productive from the support standpoint :wink:

Regards,
Mark

1 Like

OK thanks for confirming it is possible. Will try again and will post more concrete details if needed, so that we remain efficient.

Just for the record, I finally got around to solving this. I was looking to set the grouping in the definition of the view. In the end, what turned out to work was to use the “group by” parameter in the logic, not in the view definition. I had overlooked that option, focusing on “distinct”, since I felt that this was sufficient. Thanks for the help and for confirming that grouping does work across tables.