SOLVED

Calculating taxes backwards

%3CLINGO-SUB%20id%3D%22lingo-sub-2771789%22%20slang%3D%22en-US%22%3ECalculating%20taxes%20backwards%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2771789%22%20slang%3D%22en-US%22%3E%3CP%3EDear%20community%2C%20here's%20one%20for%20you%20math%20lovers!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EBasically%2C%20what%20I%20want%20to%20do%20is%20calculate%20backwards%20how%20much%20tax%20I%20have%20to%20pay%20to%20acquire%20a%20set%20amount%20after%20tax.%20See%20attached%20file%20for%20table.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20input%20in%20this%20case%20is%20usually%20the%20output%20when%20using%20these%20tax%20tables.%20Column%20A%20and%20B%20are%20the%20set%20interval%2C%20so%20a%20salary%20of%2022700%20kr%20would%20yield%20a%204634%20kr%20tax%20cut%2C%20ending%20up%20in%20roughly%2018000%20kr%20after%20taxes.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20this%20case%2C%20I%20want%20to%20use%20the%20same%20table%20to%20calculate%20it%20backwards%2C%20so%20the%20same%20example%20would%20be%20phrased%20as%2C%20how%20much%20do%20I%20have%20to%20earn%20to%20receive%20(at%20least)%2018000%20kr%20after%20taxes.%20The%20output%20needed%20is%20in%20column%20A%2C%20so%20the%20answer%20would%20be%2022601.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20at%20a%20loss%20how%20to%20program%20this%20calculation%20in%20Excel%2C%20so%20I%20would%20very%20much%20appreciate%20any%20input!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3CP%3E%2FQ%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22QWeelon_0-1632254084989.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F311870i6355865EB9B838C4%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22QWeelon_0-1632254084989.png%22%20alt%3D%22QWeelon_0-1632254084989.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2771789%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2772015%22%20slang%3D%22en-US%22%3ERe%3A%20Calculating%20taxes%20backwards%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2772015%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F912606%22%20target%3D%22_blank%22%3E%40QWeelon%3C%2FA%3E%26nbsp%3B%20This%20can%20be%20done%20using%20a%20VLOOKUP()%20or%20INDEX(MATCH())%20after%20subtracting%20the%20tax%20off%20the%20range%20(which%20could%20have%20been%20a%20helper%20column%20but%20I%20put%20into%20the%20formula).%26nbsp%3B%20%26nbsp%3BI%20converted%20the%20data%20into%20a%20table%20to%20make%20the%20data%20range%20reference%20easier%2Fbetter%20but%20you%20could%20use%20regular%20cell%20ranges%20too.%26nbsp%3B%20I%20also%20noticed%20you%20have%20multiple%20tax%20years%20on%20the%20sheet%20so%20I%20added%20the%20ability%20to%20select%20which%20year%20and%20show%20both%20the%20low%20and%20high%20of%20the%20range.%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DINDEX(Table1%5B%5BLow%5D%3A%5BHigh%5D%5D%2CMATCH(P8%2CTable1%5BLow%5D-INDEX(Table1%2C%2CMATCH(TEXT(P7%2C%220%22)%2CTable1%5B%23Headers%5D%2C0))%2C1)%2C%7B1%3B2%7D)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EIf%20you%20have%20an%20older%20version%20of%20excel%20you%20might%20need%20this%20version%20and%20you%20could%20also%20add%20an%20identical%20one%20but%20with%20%5BHigh%5D%20if%20you%20wanted%20both%20values%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DINDEX(Table1%5BLow%5D%2CMATCH(P8%2CTable1%5BLow%5D-INDEX(Table1%2C%2CMATCH(TEXT(P7%2C%220%22)%2CTable1%5B%23Headers%5D%2C0))%2C1))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2772035%22%20slang%3D%22en-US%22%3ERe%3A%20Calculating%20taxes%20backwards%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2772035%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F912606%22%20target%3D%22_blank%22%3E%40QWeelon%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESee%20the%20attached%20version%3B%20it%20uses%20XLOOKUP.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2772569%22%20slang%3D%22en-US%22%3ERe%3A%20Calculating%20taxes%20backwards%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2772569%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F127945%22%20target%3D%22_blank%22%3E%40Hans%20Vogelaar%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EVery%20nice!%20Thank%20you!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIs%20there%20a%20way%20to%20further%20augment%20this%20formula%20and%20make%20it%20even%20more%20general%20and%20safe%20for%20future%20expansion%20of%20the%20table%3F%20As%20you%20might%20have%20figured%20out%2C%20I%20will%20have%20to%20add%20another%20column%20for%20next%20year%2C%20and%20the%20next%20year%20and%20so%20on.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20input%20formula%20could%20be%20assumed%20to%20be%20the%20first%20day%20of%20the%20current%20month%2C%20using%20the%20formula%20below%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DTODAY()-DAY(TODAY())%2B1%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20again!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2773138%22%20slang%3D%22en-US%22%3ERe%3A%20Calculating%20taxes%20backwards%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2773138%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F912606%22%20target%3D%22_blank%22%3E%40QWeelon%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESee%20the%20attached%20version.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Dear community, here's one for you math lovers!

 

Basically, what I want to do is calculate backwards how much tax I have to pay to acquire a set amount after tax. See attached file for table.

 

The input in this case is usually the output when using these tax tables. Column A and B are the set interval, so a salary of 22700 kr would yield a 4634 kr tax cut, ending up in roughly 18000 kr after taxes.

 

In this case, I want to use the same table to calculate it backwards, so the same example would be phrased as, how much do I have to earn to receive (at least) 18000 kr after taxes. The output needed is in column A, so the answer would be 22601.

 

I'm at a loss how to program this calculation in Excel, so I would very much appreciate any input!

 

Regards

/Q

 

QWeelon_0-1632254084989.png

 

10 Replies

@QWeelon  This can be done using a VLOOKUP() or INDEX(MATCH()) after subtracting the tax off the range (which could have been a helper column but I put into the formula).   I converted the data into a table to make the data range reference easier/better but you could use regular cell ranges too.  I also noticed you have multiple tax years on the sheet so I added the ability to select which year and show both the low and high of the range. 

=INDEX(Table1[[Low]:[High]],MATCH(P8,Table1[Low]-INDEX(Table1,,MATCH(TEXT(P7,"0"),Table1[#Headers],0)),1),{1;2})

If you have an older version of excel you might need this version and you could also add an identical one but with [High] if you wanted both values:

=INDEX(Table1[Low],MATCH(P8,Table1[Low]-INDEX(Table1,,MATCH(TEXT(P7,"0"),Table1[#Headers],0)),1))

  

best response confirmed by QWeelon (Contributor)
Solution

@QWeelon 

See the attached version; it uses XLOOKUP.

@Hans Vogelaar 

 

Very nice! Thank you!

 

Is there a way to further augment this formula and make it even more general and safe for future expansion of the table? As you might have figured out, I will have to add another column for next year, and the next year and so on.

 

The input formula could be assumed to be the first day of the current month, using the formula below:

 

=TODAY()-DAY(TODAY())+1

 

Thank you again!

@QWeelon 

See the attached version.

Beautiful! Thank you kindly!

Have a great day!
/Q

@Hans Vogelaar 

 

Hi again,

Double checked the results and and got an error of 1 cell for certain values. See attached file for test algorithm.

 

This formula is lightyears from my Excel comprehension so I'd never be able to figure out how and if it can be tweaked.

 

Thanks again! 

@QWeelon 

That's a matter of interpretation, I think,

For an amount before tax of 18001 kr, the tax is 3384, so the amount after tax is 14617 kr.

You want 14618 kr. That is more than 14617 kr, so the formula rounds up to the next higher amount before tax.

@Hans Vogelaar 

 

Hello.

 


@Hans Vogelaar wrote:

For an amount before tax of 18001 kr, the tax is 3384, so the amount after tax is 14617 kr.


Correct. I'm with you so far - and as far as I can see the your formula works fine for the exakt value of 18001. However, if the value increased with 1kr to 18002 (up to 18100), we are still in the same tax interval (18001-18100) and the value in your formula goes to the next interval.

 

I hear what you are saying, but I'm not able to intuitively see the logic in it. In my head the values when counting forwards and backwards should match - but I've been wrong before when it comes to math..

 

/Q

@QWeelon 

OK, try this (confirmed with Ctrl+Shift+Enter:

 

=U162+INDEX(C3:R488,MATCH(INDEX(A3:A488,MATCH(U162,A3:A488-INDEX(C3:R488,0,MATCH(U159,C1:R1,0)))),A3:A488,0),MATCH(U159,C1:R1,0))

Thank you, the formula is close but not flawless. In this case both of your formulas are good enough for my intentions. I'm very grateful for your time and effort!

Thank you!
Have a good week-end!