Table Row on Web App is not consistent

Hi All,

I am automating a process for a client.
The process is, once the correct screen is open in a web app, bot needs to select Super Office, Fiscal Year, Fund Type from dropdown menu and then hit Show Distribution lines. (Show in screenshot below).
Now the scenarios are, 1- if that particular Super Office doesn’t have any previously added rows/lines then it will appear like below(SS 1). Then bot needs click on New Distribution Lines, so new blank row/line will be added to select data(SS 2). This is ideal case. But all the time this will not be case. Here is scenario 2- sometimes Super Office have data or lines/rows added previously, which will appear when bot selects that Super Office and hits Show Distribution lines(SS 3). In this case when bot hits New Distribution Line, the new line will be added underneath the previously added data and same goes with subsequent new lines(SS 4). And previously added lines/rows are not consistent in number it could be 1 or 2 or more.

Please see selectors of Lines 2,3 &4 in screenshot 5,6 & 7

Please help me to automate this so that bot can select data in both of these scenarios without any issue.

Thank you

Line 2 (Previously added data)

Line 3 (Previously added data)

Line 4 (New line)

for identifying the last row you can make benefit of the TableRow part within the selector and dynamize it like described in link below:

for calculating the current last tableRow index it can be done with the help of find children or maybe datascraping and using retrieved datatable.rows.count

Another technique is to use an integrated anchor within the selector to a last row dropdown / field using the save changes button. For this have alook here:

Thank you for responding.
Could you please explain with example? I didn’t understand.