If this is something that is repeated often, and you want to centralize the logic and not have to deal with variables at all, then a Custom Locator Strategy,
An example inspired by your question:
*** Test Cases ***
Test Case
Add Location Strategy table Custom Locator Strategy
Page Should Contain Element table=3
*** Keywords ***
Custom Locator Strategy
[Arguments] ${browser} ${criteria} ${tag} ${constraints}
${element}= Get Webelement css=.tr > td:nth-child(${criteria})
[Return] ${element}
This will then work for all keywords that takes a locator as an input argument. The Custom Locator Strategy only needs to return an Web element.
An alternative that in my view fulfills the inline criteria, but in my opinion is not more readable (leave that to the reader) is to use the string object functions. They are described in and around the Advanced Variable Syntax section of the Robot Framework Guide:
*** Variables ***
${locator_template} css=.tr > td:nth-child(%)
*** Test Cases ***
TC
Log Locator Template: "${locator_template}"
${locator} Set Variable ${locator_template.replace("%", "9")}
Log Locator Variable: "${locator}"
Log Inline Variable: "${locator_template.replace("%", "9")}"
Log Locator Template: "${locator_template}"
This example shows how to use the object functions inline. As the Python String object has the method replace, it will provide for a stable way of replacing the same variable and using it's replace output for further assignment in keywords.
It will yield the following result:
Starting test: Robot.String Replace.TC
20180513 12:25:21.057 : INFO : Locator Template: "css=.tr > td:nth-child(%)
20180513 12:25:21.058 : INFO : ${locator} = css=.tr > td:nth-child(9)
20180513 12:25:21.059 : INFO : Locator Variable: "css=.tr > td:nth-child(9)"
20180513 12:25:21.060 : INFO : Inline Variable: "css=.tr > td:nth-child(9)"
20180513 12:25:21.061 : INFO : Locator Template: "css=.tr > td:nth-child(%)"
Ending test: Robot.String Replace.TC
As you can tell the replace function returns the result, and does not update the original string. This makes it useful for using as as reusable template.
get row 32. The logic for computing the locator could be in the keyword.