Display a Sheet related field in a footprint or edit a field

Hi,
using Kicad 8.0.1

I’ve got a foot print in a hierachical sheet, that is duplicated many time (it’s a LED).
I want to display a field with the name of the LED (ledName).
So each name need to be different in each sheet.

I’ve added the text in my footprint, and I display a variable ${ledName}
I can add the field to my led symbol, and it works.
However, the field is the same for each sheet. Meaning, if I go in my second sheet, and change the LedName, it get changed also in the first sheet.

I can set the symbol field to LedName = ${SHEETNAME}
it works.
But there I’ve got an issue of string, my sheetname is LED_1 LED_2 …
And I want to display only the number. Is there a way to manipulate the string and “extract” the number, or remove the first 4 characters.

or is there another way to get a diffrent field for each sheet that I can get in the footprint ?

You can add text fields to the Properties of sheets. They belong to each sheet instance. Their names can be used as variables. So add a named field to each sheet and the name as variable inside one of those sheets. Each instance replaces the variable independently.

Thanks, this is working