0

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?

1

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:

ALTER TABLE <table>
ADD <newColumn> float(5)

https://www.w3schools.com/sql/sql_alter.asp

Then use the UPDATE function like so:

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

https://www.w3schools.com/sql/sql_update.asp

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.