Replace with the value of a page variable

I have created a page variable named “pageVars.state” that value is one state abbreviation of U.S. from my dropdown field.

I have a part of the formula:
MAP(data.state, {“id”: item.id, “stateRate”: item.state-ca)})

I want to replce “ca” with the value of “pageVars.state” variable

I’ve looked for solutions, but couldn’t find any that work. Please help. Thank you.

I don’t think this is possible with formulas at all. Instead I would suggest restructuring your data so that you would have an array of objects with the stateRates like

stateRates: [
{name: “CA”,
value: 0.345},
{name: “MI”,
value: 0.543},
]

so that you could depending on the pageVars.state get the correct rate. For example if stateRates would be an app variable:

MAP(data.state, {“id”: item.id, “stateRate”: LOOKUP(FIND_BY_KEY(appVars.stateRates,“name”,pageVars.state),“value”))})

Disclaimer: the formula may have typos as I made it up from the top of my head.

If you just want to map your item.state to have “-ca” (or whatever the selected page variable is) after it in new stateRate property, you can use MAP(data.state, {“id”: item.id, “stateRate”: item.state + "-" + pageVars.state)}) to change property name and add some more chars to the property value.