Show specific value from a related record when more than one record is "attached"

Hello everyone, I would like to ask for help:

My scenario:
I have an App A that is related to App B. In App A I want to “connect” a record to at least two records of App B. So record A1 is related to record B1 and B2.
And then I want to show a number value N1 from App B in App A in different fields. So the record A1 should show in field X the value N1 of related record B1 and in field Y the value of N1 of related record B2.

My problem:
I tried to solve this by using the tape given properties.
For field X (to show the value of the first related record B1) I used the calculation formular: (@All of N1[0]).
For field Y (to show the value of the second related record B2) I used this calculation: if (@All of N1.length > 1)@All of N1 with nulls[0]; else “0”

For most records it shows the correct values in each field although it didn’t understand why the both fields refer to index 0. but ok.
But then for some records it doesn’t work. there it shows the same value in both fields (X and Y) so from the same related record.
For context: I use a naming convention for the records that include month and year: 2023-09 and 2023-10 and in this instance my calculations don’t work. I assume the related records are alphabetically ordered, maybe

I knew from the beginning that my formular was a bit hacky and not very neat.
Can you please help me find the correct formular for this calculation? How can I determine precisely which related value I want in a specific field if more than one record is attached/connected?

Thank you