My dataset in Carto has columns with subtotals and a column with total - I would like to create a new column with the calculated percentage in Carto - is there a way to do this?


You can use SQL to do this, using the UPDATE function. From either the DATA tab on the layer that uses the dataset you want to change, or from the dataset itself, switch into SQL mode. If you don't already have a column for your results, you can add a new column using either the UI or this SQL:

ADD <newColumn> float(5)


Then use the UPDATE function like so:

UPDATE <table>
SET <newColumn>=subtotal/total


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.