How to create a calculated column with unique values ​for every field

Viewed 29

I'm currently facing a problem working with a CV on SAP HANA. Basically my goal is to create a calculated field on every row, based on the content of another field of the same row.

More specifically, I have a column of dates with the current format (YYYYMMDD) and I have to automatically create an associated field based on current criterias:

  1. the date with the current month and year has to be associated with 0;
  2. every month after the current one, has to be, in order, increased by one (example: for 20220930 I have 0, for 20221030 I have 1, for 20221230 I have 3.. for 20231230 I have 15, this until 600);
  3. if more than one row has the same date, the calculated field has to be the same, that means that, for example, if more than one row has 20221030, I need to have 1 on all of them).

My first idea was to use a rank node, but the outcome is not as I expected. Attached, there is a screenshot of a data preview of my attempt (just showing the dates and rank_field columns..).

Any advice is welcome, thanks.

Example of data

0 Answers
Related