Need help to Combine 2 formulas

RAJESH1960

Banned for repeated rules violations
Joined
Mar 26, 2020
Messages
2,313
Office Version
  1. 2019
Platform
  1. Windows
Hello experts

I am trying to combine 2 formulas and trying to apply to get the same result I used to get by using 2 different formulas. But I am getting an error.

=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(K:K,C:C,C2,E:E,E2),"") to get the combined local tax

=IF(COUNTIFS(C$2:C10,C10,E$2:E10,E10)=1,SUMIFS(I:I,C:C,C10,E:E,E10),"") to get the combined interstate tax

As in every new data the range changes, I need to change the range every time. So, I tried to combine both the formulas with this formula

=IF(12=0,COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(K:K,C:C,C2,E:E,E2),COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(I:I,C:C,C2,E:E,E2)))

But I am not able to get the formula right.

query to combine tax IGST + CGST in one formula.xlsx
ABCDEFGHIJK
1abcdefghInterstateCombine TaxLocal
2124AAHCS4768D4Z7TAX/0488/21-22473.8800
3224AAHCS4768D4Z7TAX/0699/21-221269.900
4324AAHCS4768D4Z7TAX/0699/21-221401.83FALSE0
5424AAHCS4768D4Z7TAX/0715/21-22338.6400
6524AAHCS4768D4Z7TAX/0730/21-22348.100
7624AAHCS4768D4Z7TAX/0789/21-221553.6400
8724AAHCS4768D4Z7TAX/0789/21-22437.52FALSE0
9824AAHCS4768D4Z7TAX/0798/21-22480.2700
10924AAHCS4768D4Z7TAX/0813/21-221058.2500
111024AAHCS4768D4Z7TAX/0834/21-22634.9500
121124AAHCS4768D4Z7TAX/0834/21-22527.63FALSE0
131224AAHCS4768D4Z7TAX/0900/21-22479.1900
141324AAHCS4768D4Z7TAX/0918/21-222716.800
151424AAHCS4768D4Z7TAX/0918/21-22859.78FALSE0
161529AAACT9430G1Z7BLR7-98106.556.55
171629AAAFI7960D1ZBRBR22E000721062304.18
181729AAAFI7960D1ZBRBR22E0007210FALSE4461.73
191829AAAFI7960D1ZBRBR22E0007210FALSE1764.09
201929AABFI4434R1ZUKA010003210003060726.38336.64
212029AABFI4434R1ZUKA010003210003060FALSE389.74
222129ABHPC1918R1Z8ICHABE21220000440155.710.24
232229ABHPC1918R1Z8ICHABE21220000440FALSE37.41
242329ABHPC1918R1Z8ICHABE21220000440FALSE118.06
252429ADDFS6267R1Z10114/2021-22074.1774.17
262529ADDFS6267R1Z10236/2021-220389.659
272629ADDFS6267R1Z10236/2021-220FALSE380.65
282729ADDFS6267R1Z10244/2021-220735.1120.25
292829ADDFS6267R1Z10244/2021-220FALSE714.86
302929AGHPY0797M1ZB107027002700
313029AGHPY0797M1ZB11802685.62685.6
323129FZBPS6969D1ZO27702858.42858.4
333229FZBPS6969D1ZO281029972997
343329FZBPS6969D1ZO284033303330
353429FZBPS6969D1ZO285023942394
363506AXFPA2657R1Z58303000
373606BOVPG2947E1ZQ08-2021-20221555.200
383706BOVPG2947E1ZQ08-2021-20222118FALSE0
393809AAACI5853L2Z518124941322924.0900
403909AAACI5853L2Z51812603555762.7100
414009AJHPM4274A1ZB507210000
424109AJHPM4274A1ZB508113600
434209AJHPM4274A1ZB51030000
444319AAACT9430G1Z8SCCH-308313.100
Combine Tax
Cell Formulas
RangeFormula
J2:J44J2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(K:K,C:C,C2,E:E,E2),IF(12=0,IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(I:I,C:C,C2,E:E,E2))))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E2:E44Expression=COUNTIFS(C$2:C$19991,C2,E$2:E$19991,E2)>1textNO
 
Last edited:

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
=IF(12=0,COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(K:K,C:C,C2,E:E,E2),COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(I:I,C:C,C2,E:E,E2))))
even this is not working
 
Upvote 0
query to combine tax IGST + CGST in one formula.xlsx
ABCDEFGHIJKL
1abcdefghcombine InterstateInterstateCombine localLocal
21529AAACT9430G1Z7BLR7-9816.556.556.55
31629AAAFI7960D1ZBRBR22E000721623062304.18
41729AAAFI7960D1ZBRBR22E000721  4461.73
51829AAAFI7960D1ZBRBR22E000721  1764.09
61929AABFI4434R1ZUKA01000321000306726.38726.38336.64
72029AABFI4434R1ZUKA01000321000306  389.74
82129ABHPC1918R1Z8ICHABE2122000044155.71155.710.24
92229ABHPC1918R1Z8ICHABE2122000044  37.41
102329ABHPC1918R1Z8ICHABE2122000044  118.06
112429ADDFS6267R1Z10114/2021-2274.1774.1774.17
122529ADDFS6267R1Z10236/2021-22389.65389.659
132629ADDFS6267R1Z10236/2021-22  380.65
142729ADDFS6267R1Z10244/2021-22735.11735.1120.25
152829ADDFS6267R1Z10244/2021-22  714.86
162929AGHPY0797M1ZB107270027002700
173029AGHPY0797M1ZB1182685.62685.62685.6
183129FZBPS6969D1ZO2772858.42858.42858.4
193229FZBPS6969D1ZO281299729972997
203329FZBPS6969D1ZO284333033303330
213429FZBPS6969D1ZO285239423942394
224319AAACT9430G1Z8SCCH-308313.113.100
234209AJHPM4274A1ZB51030030000
24424AAHCS4768D4Z7TAX/0715/21-22338.64338.6400
25524AAHCS4768D4Z7TAX/0730/21-22348.1348.100
26724AAHCS4768D4Z7TAX/0789/21-221991.16437.5200
27124AAHCS4768D4Z7TAX/0488/21-22473.88473.8800
281224AAHCS4768D4Z7TAX/0900/21-22479.19479.1900
29824AAHCS4768D4Z7TAX/0798/21-22480.27480.2700
301124AAHCS4768D4Z7TAX/0834/21-221162.58527.6300
311024AAHCS4768D4Z7TAX/0834/21-22 634.95 0
323909AAACI5853L2Z51812603555762.71762.7100
331424AAHCS4768D4Z7TAX/0918/21-223576.58859.7800
34924AAHCS4768D4Z7TAX/0813/21-221058.251058.2500
354109AJHPM4274A1ZB5081136113600
36224AAHCS4768D4Z7TAX/0699/21-222671.731269.900
37324AAHCS4768D4Z7TAX/0699/21-22 1401.83 0
38624AAHCS4768D4Z7TAX/0789/21-22 1553.64 0
393606BOVPG2947E1ZQ08-2021-20223673.21555.200
404009AJHPM4274A1ZB5072100210000
413706BOVPG2947E1ZQ08-2021-2022 2118 0
421324AAHCS4768D4Z7TAX/0918/21-22 2716.8 0
433809AAACI5853L2Z518124941322924.092924.0900
443506AXFPA2657R1Z583030303000
Combine Tax
Cell Formulas
RangeFormula
J2:J21J2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(L:L,C:C,C2,E:E,E2),"")
I22:I44I22=IF(COUNTIFS(C$2:C22,C22,E$2:E22,E22)=1,SUMIFS(J:J,C:C,C22,E:E,E22),"")
K2:K44K2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(L:L,C:C,C2,E:E,E2),"")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E2:E44Expression=COUNTIFS(C$2:C$19991,C2,E$2:E$19991,E2)>1textNO


This is the right result in 2 different columns. This is how I use the formula part by part. I have to insert 2 additional columns to get the right result. The problem is I have to change the range every time in different data.
 
Upvote 0
I'm confused by what you mean by the range changing. I assume you add new rows at the bottom. The formulas just need to be copied down to the new rows. The ranges in the formulas will adapt appropriately. Consider this:

Book1 (version 1).xlsb
ABCDEFGHIJKLMNO
1abcdefghInterstateCombine TaxLocalCombined Local taxCombined Interstate taxCombined Tax
2124AAHCS4768D4Z7TAX/0488/21-22473.88473.8800473.88473.88
3224AAHCS4768D4Z7TAX/0699/21-221269.92671.73002671.732671.73
4324AAHCS4768D4Z7TAX/0699/21-221401.83 0   
5424AAHCS4768D4Z7TAX/0715/21-22338.64338.6400338.64338.64
6524AAHCS4768D4Z7TAX/0730/21-22348.1348.100348.1348.1
7624AAHCS4768D4Z7TAX/0789/21-221553.641991.16001991.161991.16
8724AAHCS4768D4Z7TAX/0789/21-22437.52 0   
9824AAHCS4768D4Z7TAX/0798/21-22480.27480.2700480.27480.27
10924AAHCS4768D4Z7TAX/0813/21-221058.251058.25001058.251058.25
111024AAHCS4768D4Z7TAX/0834/21-22634.951162.58001162.581162.58
121124AAHCS4768D4Z7TAX/0834/21-22527.63 0   
131224AAHCS4768D4Z7TAX/0900/21-22479.19479.1900479.19479.19
141324AAHCS4768D4Z7TAX/0918/21-222716.83576.58003576.583576.58
151424AAHCS4768D4Z7TAX/0918/21-22859.78 0   
161529AAACT9430G1Z7BLR7-98106.556.556.5506.55
171629AAAFI7960D1ZBRBR22E000721062304.18623006230
181729AAAFI7960D1ZBRBR22E0007210 4461.73   
191829AAAFI7960D1ZBRBR22E0007210 1764.09   
201929AABFI4434R1ZUKA010003210003060726.38336.64726.380726.38
212029AABFI4434R1ZUKA010003210003060 389.74   
222129ABHPC1918R1Z8ICHABE21220000440155.710.24155.710155.71
232229ABHPC1918R1Z8ICHABE21220000440 37.41   
242329ABHPC1918R1Z8ICHABE21220000440 118.06   
252429ADDFS6267R1Z10114/2021-22074.1774.1774.17074.17
262529ADDFS6267R1Z10236/2021-220389.659389.650389.65
272629ADDFS6267R1Z10236/2021-220 380.65   
282729ADDFS6267R1Z10244/2021-220735.1120.25735.110735.11
292829ADDFS6267R1Z10244/2021-220 714.86   
302929AGHPY0797M1ZB107027002700270002700
313029AGHPY0797M1ZB11802685.62685.62685.602685.6
323129FZBPS6969D1ZO27702858.42858.42858.402858.4
333229FZBPS6969D1ZO281029972997299702997
343329FZBPS6969D1ZO284033303330333003330
353429FZBPS6969D1ZO285023942394239402394
363506AXFPA2657R1Z58303030300030303030
373606BOVPG2947E1ZQ08-2021-20221555.23673.2003673.23673.2
383706BOVPG2947E1ZQ08-2021-20222118 0   
393809AAACI5853L2Z51.81E+092924.092924.09002924.092924.09
403909AAACI5853L2Z51.81E+09762.71762.7100762.71762.71
414009AJHPM4274A1ZB507210021000021002100
424109AJHPM4274A1ZB508113611360011361136
434209AJHPM4274A1ZB51030030000300300
444319AAACT9430G1Z8SCCH-308313.113.10013.113.1
Sheet34
Cell Formulas
RangeFormula
L2:L44L2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(K:K,C:C,C2,E:E,E2),"")
M2:M44M2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(I:I,C:C,C2,E:E,E2),"")
J2:J44J2=IF(L2<>"",L2+M2,"")
O2:O44O2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(K:K,C:C,C2,E:E,E2)+SUMIFS(I:I,C:C,C2,E:E,E2),"")


Here columns A:I and column K is the raw data. The formula in L2 is the combined local tax. The formula in M2 is the combined Interstate tax. To get the sum of them, you can just add those totals, which I did with the J2 formula. If you want to get the J2 total, without the L2 and M2 formulas, the combined version is in the O2 formula.

Let me know if this is what you want.
 
Upvote 0
See if this does what you need
J2 copied down
=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,IF(I2<>0,SUMIFS(I:I,C:C,C2,E:E,E2),SUMIFS(K:K,C:C,C2,E:E,E2)),"")

M.
 
Upvote 0
Solution
Simpler version
J2 copied down
=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(IF(I2<>0,I:I,K:K),C:C,C2,E:E,E2),"")

M.
 
Upvote 0
I'm confused by what you mean by the range changing. I assume you add new rows at the bottom. The formulas just need to be copied down to the new rows. The ranges in the formulas will adapt appropriately. Consider this:

Book1 (version 1).xlsb
ABCDEFGHIJKLMNO
1abcdefghInterstateCombine TaxLocalCombined Local taxCombined Interstate taxCombined Tax
2124AAHCS4768D4Z7TAX/0488/21-22473.88473.8800473.88473.88
3224AAHCS4768D4Z7TAX/0699/21-221269.92671.73002671.732671.73
4324AAHCS4768D4Z7TAX/0699/21-221401.83 0   
5424AAHCS4768D4Z7TAX/0715/21-22338.64338.6400338.64338.64
6524AAHCS4768D4Z7TAX/0730/21-22348.1348.100348.1348.1
7624AAHCS4768D4Z7TAX/0789/21-221553.641991.16001991.161991.16
8724AAHCS4768D4Z7TAX/0789/21-22437.52 0   
9824AAHCS4768D4Z7TAX/0798/21-22480.27480.2700480.27480.27
10924AAHCS4768D4Z7TAX/0813/21-221058.251058.25001058.251058.25
111024AAHCS4768D4Z7TAX/0834/21-22634.951162.58001162.581162.58
121124AAHCS4768D4Z7TAX/0834/21-22527.63 0   
131224AAHCS4768D4Z7TAX/0900/21-22479.19479.1900479.19479.19
141324AAHCS4768D4Z7TAX/0918/21-222716.83576.58003576.583576.58
151424AAHCS4768D4Z7TAX/0918/21-22859.78 0   
161529AAACT9430G1Z7BLR7-98106.556.556.5506.55
171629AAAFI7960D1ZBRBR22E000721062304.18623006230
181729AAAFI7960D1ZBRBR22E0007210 4461.73   
191829AAAFI7960D1ZBRBR22E0007210 1764.09   
201929AABFI4434R1ZUKA010003210003060726.38336.64726.380726.38
212029AABFI4434R1ZUKA010003210003060 389.74   
222129ABHPC1918R1Z8ICHABE21220000440155.710.24155.710155.71
232229ABHPC1918R1Z8ICHABE21220000440 37.41   
242329ABHPC1918R1Z8ICHABE21220000440 118.06   
252429ADDFS6267R1Z10114/2021-22074.1774.1774.17074.17
262529ADDFS6267R1Z10236/2021-220389.659389.650389.65
272629ADDFS6267R1Z10236/2021-220 380.65   
282729ADDFS6267R1Z10244/2021-220735.1120.25735.110735.11
292829ADDFS6267R1Z10244/2021-220 714.86   
302929AGHPY0797M1ZB107027002700270002700
313029AGHPY0797M1ZB11802685.62685.62685.602685.6
323129FZBPS6969D1ZO27702858.42858.42858.402858.4
333229FZBPS6969D1ZO281029972997299702997
343329FZBPS6969D1ZO284033303330333003330
353429FZBPS6969D1ZO285023942394239402394
363506AXFPA2657R1Z58303030300030303030
373606BOVPG2947E1ZQ08-2021-20221555.23673.2003673.23673.2
383706BOVPG2947E1ZQ08-2021-20222118 0   
393809AAACI5853L2Z51.81E+092924.092924.09002924.092924.09
403909AAACI5853L2Z51.81E+09762.71762.7100762.71762.71
414009AJHPM4274A1ZB507210021000021002100
424109AJHPM4274A1ZB508113611360011361136
434209AJHPM4274A1ZB51030030000300300
444319AAACT9430G1Z8SCCH-308313.113.10013.113.1
Sheet34
Cell Formulas
RangeFormula
L2:L44L2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(K:K,C:C,C2,E:E,E2),"")
M2:M44M2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(I:I,C:C,C2,E:E,E2),"")
J2:J44J2=IF(L2<>"",L2+M2,"")
O2:O44O2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(K:K,C:C,C2,E:E,E2)+SUMIFS(I:I,C:C,C2,E:E,E2),"")


Here columns A:I and column K is the raw data. The formula in L2 is the combined local tax. The formula in M2 is the combined Interstate tax. To get the sum of them, you can just add those totals, which I did with the J2 formula. If you want to get the J2 total, without the L2 and M2 formulas, the combined version is in the O2 formula.

Let me know if this is what you want.
Thanks for responding Eric W.
 
Upvote 0

Forum statistics

Threads
1,223,643
Messages
6,173,520
Members
452,518
Latest member
SoerenB

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top