3

I have records with variable number of rows and a column A with 7 possible values, all of them are repeatable.

I need a new column B based on A showing the number of occurrencies of each value per record. The count should reset in every record.

I managed to sort my rows in column A ordering them alphabetically within each record, but I can’t find the right expression to do the counting. I could only manage to obtain the total count of occurrencies of the values in A through all the data set (using text facet or facetCount).

Any clues?

pasq87
  • 31
  • 1

2 Answers2

1

If you have this...

enter image description here

... and want this...

enter image description here

... the easiest way is to switch on Jython/Python (instead of GREL) and use this formula in a "Add column based on this column" window:

return row.record.cells['col2'].value.count(value)

Just replace col2 by your actual column name of course

Ettore Rizza
  • 2,800
  • 2
  • 11
  • 23
0

I found the following GREL expression on the mailing list row.record.toRowIndex-row.record.fromRowIndex

It executes faster on larger projects.

magdmartin
  • 1,712
  • 3
  • 20
  • 43