Adib Murtadha
 · Software Architect at Sahid Jaya Foundation

How to do multiple count ?

Hello everyone.

I have data that looks like this(bottom):

What I want to do is to count this data but with filtering but without using query OR, if I use OR query it'll + the count query and it'll be a total count.

I want to count specific data side by side.

I think the response should looks like this:

[{count25201: 3,
count61201: 2,
count70201: 1}]

OR

[{
msu_nama: Teknik Lingkungan,
count: 3},
{
msu_nama: Manajemen
count: 2},
{
msu_nama: Ilmu Komunikasi},
count: 1}]

OR

[{
Teknik_Lingkungan: 3,
Manajemen: 2,
Ilmu_Komunikasi: 1
}]

Can I achive it with Xano?

The only way that works right now. I just need to make API count 1, API count 2, API count 3, and so on. But, I think that's not the correct way to do it. So I want to know another ways to do it properly.

This is my endpoint:

This is query all records filter, I do joins and query here:

This is my evals:

I do custom response:

This is my count array right now which is still wrong because it's only calculate all the filter, if I use AND it'll show 0/null response:

Please help me to solve it.

Thanks a lot.

[
{
sp_idunit: 25201,
msu_nama: Teknik Lingkungan},
{
sp_idunit: 61201,
msu_nama: Manajemen},
{
sp_idunit: 25201,
msu_nama: Teknik Lingkungan},
{
sp_idunit: 62201,
msu_nama: Akuntansi},
{
sp_idunit: 70201,
msu_nama: Ilmu Komunikasi},
{
sp_idunit: 13211,
msu_nama: GIZI},
{
sp_idunit: 26201,
msu_nama: Teknik Industri},
{
sp_idunit: 25201,
msu_nama: Teknik Lingkungan},
{
sp_idunit: 61201,
msu_nama: Manajemen}]
4 replies