Today I found out a simple way to create a variable name based on a calculation.
Given a record with a primary key, say, Key_Job_ID = 12345 for example, you can create a variable called $$12345.stack with this calculation:
Evaluate ( "Let ( $$" & Jobs::KEY_Job_ID & ".Stack = ExecuteSQL ( \"SELECT Key_Job_ID , KEY_JobLineItem_ID FROM Jobs_LineItems WHERE Key_Job_ID=? ORDER BY PortalSortOrder\" ; \"-\" ; \"\¶\" , Jobs::Key_Job_ID ) ; $$" & Jobs::KEY_Job_ID & ".Stack )" )
Jobs is the base table.
Key_Job_ID is the primary key field for this table.
In this case I wanted to populate the variable with the result of a ExecuteSQL query but you can put any calculation you want, just be careful with quotes, they must be properly escaped in order to work.
Hope you find this useful.