Tutorials & Examples Web-help Blog

New Enumeration for each key


#1

Hi,

I know it’s possible, but I wonder whether there will be an easier solution.
In my example, I have a file with different columns. In the attached file, reduced it to two colums, which should be the concatenated key of the file.
key iteration.csv (254 Bytes)
What I would like to have is an enumeration for each combination of these keys.

Is there no easier way to enumerate depending on two fields without another (sub-)project?

Kind regards,

Jochen


#2

Yes, there is a very easy way:

Remove duplicates (using the “Deduplicate” action).
Enumerate remaining unique combinations using the “Enumerate rows” action.

See the example below:
enumerated-combinations.morph (3.1 KB)


#3

Hi Dmitry,

thanks for your quick reply. The solution is good, but the result is not what i expected. :wink:
I’m afraid that my explanation of the problem was wrong or misunderstanding.

I need an enumeration for each key, so what I expected would be like this:

|Date|keyfield2|->IDperKey

|01.03.2019|1| ->1 (first row for this key combination)
|01.03.2019|2| ->1 (first row for this key combination)
|01.03.2019|3| ->1 (first row for this key combination)
|02.03.2019|1| ->1 (first row for this key combination)
|03.03.2019|1| ->1 (first row for this key combination)
|03.03.2019|1| ->2 (this row key is the same as the one before)
|04.03.2019|1| ->1 (first row for this key combination)
|04.03.2019|2| ->1 (first row for this key combination)
|04.03.2019|3| ->1 (first row for this key combination)
|03.03.2019|1| ->3 (same key as the record 4 rows before)
|03.03.2019|1| ->4 (same key as the record before)
|04.03.2019|2| ->2 (same key as the record 4 rows before)
|04.03.2019|2| ->3 (same key as the record before)
|04.03.2019|2| ->4 (same key as the record before)
|04.03.2019|2| ->5 (same key as the record before)
|04.03.2019|2| ->6 (same key as the record before)
|04.03.2019|2| ->7 (same key as the record before)

For every repeated key the number should be increased.

Yours,

Jochen


#4

Oh, that’s even simpler. The “Running total” action in the “Count” mode would enumerate rows in groups.

See the example below. Note that the target column can be any of the two (as long as it doesn’t have empty values).

enumeration-in-groups.morph (2.2 KB)

image


#5

That’s brilliant! I was trying various things, but this one was too easy. My fault. :wink:
Thank you very much. This helps me a lot.
I really like this product!:+1:


#6

You’re welcome!