Author Topic: Grouping  (Read 2377 times)

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Grouping
« on: September 24, 2018, 02:20:29 pm »
When having rows with certain values with multidimension structure...would it be possible to group by those values?
How to handle aggregated data since fact only should be counted once?


« Last Edit: September 24, 2018, 02:23:56 pm by queensgambit9 »

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Grouping
« Reply #1 on: September 24, 2018, 06:33:00 pm »
it can be done by adding a formula column to extract primitive values and use this column for grouping.

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Grouping
« Reply #2 on: September 24, 2018, 08:49:24 pm »
Hmm...got a short example? Not sure how to implement it.
The values are in the response from DB (multiple rows with different group but same fact)...

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Grouping
« Reply #3 on: September 25, 2018, 10:43:44 am »
There are already couple of examples on formula columns https://paramquery.com/pro/demos/grid_formula

and row grouping https://paramquery.com/pro/demos/group_rows

I can help you with more relevant example if share the structure of your rows with certain values with multidimension structure....

queensgambit9

  • Pro Ultimate
  • Sr. Member
  • *
  • Posts: 341
    • View Profile
Re: Grouping
« Reply #4 on: October 04, 2018, 05:24:36 pm »
Thanks.

Example:

type   category   id   value
-----------------------------
test   cat 1      1   10
test   cat 2      1   10
test   cat 2      2   30

Grouping on "type" with SUM will give "test SUM 50", correct in my case should be 40 since row with "id" 1 occurs multiple times...

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Grouping
« Reply #5 on: October 04, 2018, 06:33:50 pm »
Thanks for the example.

It can be solved in paramquery spreadsheet by use of this formula

=IF(COUNTIF($A$1:A1,A1)=1,B1,"")

https://superuser.com/questions/132700/excel-sum-that-excludes-duplicates

But Excel formulas can't be used in the place of row grouping aggregates and js formulas can't cross reference other rows, so I don't see any way to do it in case of row grouping.