# How can I use group(multiple criteria)?

How can I use group(multiple criteria)?

Hi! Can you please give an example of what youāre trying to do, Iāll see if I can come up with a formula to do it?

i want to do multiple criteria for group by!

like this

SELECT
dept
, salary
, COUNT(*)
, COUNT(salary)
, count(dept)
, count(name)
FROM
salary_sample
GROUP BY
dept, salary; ā multiple (2) criteria!

now , i can use GROUP(single criteria).
like this

SELECT
dept
, salary
, COUNT(salary)
FROM
salary_sample
GROUP BY
, salary; āsingle criteria!
ā In single criteria case , I understand , How I use GROUP().
this case I should use GROUP(salary_sample ,item.salary, key ,count(items) ).
I want know how write GROUP(āmultiple criteriaā)
I try to write GROUP(salary_sample ,[item.salary, item.dept], key ,count(items) ).
But it didnāt workā¦

Can you understand about i said ?
Iām not good at englishā¦ sorryā¦!
and iām beginner of this āappgyverā.

Hi,

Excellent question! Unfortunately, `GROUP` or other functions does not (yet) directly have the feature to use multiple grouping criteria, but there might be some workarounds to solve your problem!

One thing that you could try is to combine the two grouping criterias temporarily to a single one, and then separate them later! So for example: you could combine dept and salary as a text string where these are separated by a `:` character (or any other character): `item.dept + ":" + item.salary`

Now, this combined text will become your group `key`, and if you then want to separate them later in your formula, you could use `SPLIT`:

• To get the dept: `PICK_ITEM(SPLIT(key, ":"), 0)`
• To get the salary: `PICK_ITEM(SPLIT(key, ":"), 1)`

Note that the values above are now text. If youād like to convert them to numbers, then you should wrap them with an additional `NUMBER(ā¦)`

wow!

thank you !iāll try it.
this time i closing this QA.

i want to calculate after grouping.
if I can"t , I establish new QA!

1 Like