Calculate tax %

Hi, in my country tax for gains made in stocks go like this:

https://i.postimg.cc/7h7gyXZ4/retenciones-irpf-2021.png

This means that from 0€ to 12450€ you pay 19%
from 12450€ to 20200€ you pay 24%

etc

I was wondering how I could enter a number in a cell, then have the result in another. I don’t know how to split the amounts in chunks to get each rate % so you can get the total to pay.

There are different ways to work with stepped rates of the kind.

Though this wasn’t explicitly stated, I assumed that each rate only applies to the part of the base amount (taxable income?) between the respective limits.

Two ways usable to get a table of tax amounts depending on the taxed base values are exemplified in the attached file.

The first one uses a rather complicated formula and doesn’t need any helpers. The second way makes extensive use of helper columns.

I didn’t suggest a formula omitting the visible table of rates by directly including the information. Too unhandy.

disask66788TaxWithSteppedRate.ods (46.5 KB)

1 Like

Not sure about how the rest works but im using the formula one and it works fine. However I realized the taxes I need are as following:

https://i.postimg.cc/MKpCbL8N/impuestos-irpf-2021.jpg

It’s the column on the right. I tried displacing the color boxes to make it fit within these rates but im doing something wrong. Could you possibly upload an ods that does the same but with the rates of the right?

I cant undersand the formula to modify manually like I said I tried to adjust the overlaping color boxes into the other rates but I get confused and something it’s not working.

-1- Basically you don’t need to adjust anything as long as a different table hasn’t more rows than the given one. In this case simply enter the correct numbers into the given table, use 1E308 representing positive infinity, and copy the final row (1E308; 26%) down to the otherwise unused rows of the table.
-2- Don’t post images expecting helpers to type numbers read from the image.
-3- Don’t use a spreadsheet without an understanding of the used formulas. How will you tell whether it “works fine” or returns wrong results in some cases. I surely will not accept resposibility. You can’t decide such a question based on a few exsamples checked with a pencil on paper.
-4- Which “column on the right” are you talking of?
I attach a new example also containing a solution “just for fiun” and one based on a user function (fourth sheet). The last mentioned one can only work if document macros are permitted. It tackles the task from a mathematical point of view.

Always check doument macros for the absence of malign code before you permit their execution!!
disask66788TaxWithSteppedRateGeneralizedToIntegrationOfStepfuctionsVariant.ods (58.6 KB)

2 Likes

I managed to make it work doing that. However my question is, how do you check if a file has harmful code on it? I only have the Windows 10 default antivirus.

I wouldn’t expect antivirus software to detect harmful code in document macros. You need to inspect the code. If there are no commands (statements) accessing files this should do generally.

How do you access the code without opening it with Calc? I would assume once you’ve opened it it’s too late.

If you set “medium” macro security (Never set “low”!) you are asked for the permission to run it when loading the document. If you deny the permission, the contained code will not run, but is loaded, and you can study it in the IDE.