I am having a table where two columns are "ID"
and "maintenance_ID"
. The "ID"
column is unchangeable and comes from another table but the "maintenance_ID"
is calculated from other fields like the "Date"
.
Example:
ID Date maintenance_ID
EH001 21/11/2020 EH001M20201121
EH001 21/11/2020 EH001M20201121
EH002 21/11/2020 EH002M20201121
To create the "maintenance_ID"
I am using the following code:
"ID" + 'M' + format_date("Date", 'yyyyMMdd')
What I would like to do is adding to this formula a parameter where generates a new number at the end of the "maintenance_ID"
to make it unique. As you can see in my example the two first records are the same so I would like to add a "0" to the first one and a "1" to the second one and so on until 9 ( I won't be more than 9 records with the same "ID"
. Example:
maintenance_ID
EH001M202011210
EH001M202011211
EH002M202011210
Anyone knows what can I add to my expression to achieve this?