How can I use group(multiple criteria)?

How can I use group(multiple criteria)?
please help!

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?

thanks to ask for me!

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