Parameter value as column name

Hello there.

I have a dropdown of parameter values for variable_x and variable_y.
A user can choose one of these via a dashboard dropdown: color_score, color_bias, color_ranking, color_result, etc. This changes the value (i.e., the selected name) of variable_x and variable_y.

The resulting table looks something like this:

However, instead of having separate columns, I’d like the column title of value_x and value_y to change. Ideally, it’d look as follows:

Is this possible in Redash? If so, please advise. Thank you!


Extra info:

Summary

The query is as follows:

method: 
    post
url: 
  https://core.com:123/models/123abc/latest/model
headers : 
    content-type: application/json
data: '{"data": {"event": {"params": {"favorite": "{{favorite}}", "color_scale": "{{color_scale}}", "x_variable": "{{x_variable}}", "y_variable": "{{y_variable}}" }}, "context": 100}}'
path: result

I’ve tried doing this in the backend, where I add two new columns based on the parameter chosen. The API itself works perfectly in the backend (tested in Python). However, when the query is made in Redash, I get an error: headers.Access-Control-Allow-Origin, which I believe relates to CORS, which doesn’t seem to be fully implemented in Redash.

The JSON query runner doesn’t have the ability to alias column names like this. You could approximate the behaviour using the Query Results Data Source. Alternatively, you could write a custom query runner for this API that would permit more flexible handling of column names.

This is an issue with your target API, not with Redash. The only way this error would apply to Redash is if you were using Redash’s API.

Thank you for the response and pointing me in the right direction, Jesse.

Even though the API worked in Python, it wouldn’t let me send it elsewhere. I checked the build log, export log, and instance log. The first two were fine (the 200 error codes led me to believe it may have been the front end that was the issue), but the insance log had a nasty bug that didn’t like me selecting an element from a dataframe that was formed from the parameters. Pointing it to the parameter itself and modifying it worked.

It is now working as intended!