Need to add one condition to the formula

RAJESH1960

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

I need your expert help to add a condition to the formula. I want to edit the formula in column J to get the correct result. If the rates in column N are different then the formula in column J should add the taxable value in column H and display in column J. If the rates in column N are same then the formula in column J should not add the taxable value but show one value only in column J.

Book1
ABCDEFGHIJKLMNO
1ABTINNAMEInvoice numberCDTaxable Value (₹)IGSTcombine taxableCombined TaxCGSTSGSTRate (%)
2152439AKXPR3359E3ZJCustomer 1IN-ZSHB-371052159.320.002159.32194.34194.34194.3418
31139AALCA3377L3Z6Customer 2SMN008305200257711863.560.0023727.122135.441067.721067.7218MISTAKE
433839AALCA3377L3Z6Customer 2SMN008305200257711863.560.00Delete RowDelete Row1067.721067.7218
5164534AAECB3833N3ZUCustomer 3GST-53026733.501336.6826733.501336.680.000.005
68639AACCC8357H3ZECustomer 4181/2020-211300.000.001300.00117.00117.00117.0018
7161539ABHPC3938R3Z8Customer 5ICHABE202100050412480.500.0018540.341968.331123.251123.2518CORRECT
8161639ABHPC3938R3Z8Customer 5ICHABE20210005046031.270.00Delete RowDelete Row844.37844.3728
9161739ABHPC3938R3Z8Customer 5ICHABE202100050428.570.00Delete RowDelete Row0.710.715
1037737AELPN4353H3ZCCustomer 6IN-462531072.88193.122145.76386.240.000.0018MISTAKE
116837AELPN4353H3ZCCustomer 6IN-462531072.88193.12Delete RowDelete Row0.000.0018
1261839AAJFD5433B3ZRCustomer 7KA-1176-20-2151509.520.0051509.521287.741287.741287.745
1378339AAJFD5433B3ZRCustomer 7KA-1274-20-212761.900.0025714.581446.2169.0569.055CORRECT
1478439AAJFD5433B3ZRCustomer 7KA-1274-20-2122952.680.00Delete RowDelete Row1377.161377.1612
15178237AAHPG6373H3ZOCustomer 82020-21-124326880.001344.0026880.001344.000.000.005
COMBINE TAXABLE VALUE
Cell Formulas
RangeFormula
J2:J15J2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUMIFS(H:H,C:C,C2,E:E,E2),"Delete Row")
K2:K15K2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,IF(I2<>0,SUMIFS(I:I,C:C,C2,E:E,E2),SUMIFS(L:L,C:C,C2,E:E,E2)),"Delete Row")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E2:E15Expression=COUNTIFS(D$2:D$15,D2,E$2:E$15,E2)>1textNO
 
I did find a way to do it in a single column (only done with the first one so far). As I suspected though, it is far more complex and inefficient.

I've set this formula to the exact ranges in the sample sheet, it could be done a bit bigger as required but full columns will take ages to calculate, that is assuming that excel doesn't crash under the load. I attempted the sample with full columns and had to force close excel because it was taking to long to process.

If you want to go with this method then dynamic named ranges (or structured tables) would be most sensible way to set the correct ranges for the formula to use. If you have a lot of data (1000's of rows) then I would strongly advise sticking with the extra column.
Book1
ABCDEFGHIJKLMN
1ABTINNAMEInvoice numberCDTaxable Value (₹)IGSTCombined TaxableCombined TaxCGSTSGSTRate (%)
2152439AKXPR3359E3ZJCustomer 1IN-ZSHB-371052159.3202159.32194.34194.34194.3418
31139AALCA3377L3Z6Customer 2SMN008305200257711863.56011863.562135.441067.721067.7218
433839AALCA3377L3Z6Customer 2SMN008305200257711863.560Delete RowDelete Row1067.721067.7218
5164534AAECB3833N3ZUCustomer 3GST-53026733.51336.6826733.51336.68005
68639AACCC8357H3ZECustomer 4181/2020-2113000130011711711718
7161539ABHPC3938R3Z8Customer 5ICHABE202100050412480.5018540.341968.331123.251123.2518
8161639ABHPC3938R3Z8Customer 5ICHABE20210005046031.270Delete RowDelete Row844.37844.3728
9161739ABHPC3938R3Z8Customer 5ICHABE202100050428.570Delete RowDelete Row0.710.715
1037737AELPN4353H3ZCCustomer 6IN-462531072.88193.121072.88386.240018
116837AELPN4353H3ZCCustomer 6IN-462531072.88193.12Delete RowDelete Row0018
1261839AAJFD5433B3ZRCustomer 7KA-1176-20-2151509.52051509.521287.741287.741287.745
1378339AAJFD5433B3ZRCustomer 7KA-1274-20-212761.9025714.581446.2169.0569.055
1478439AAJFD5433B3ZRCustomer 7KA-1274-20-2122952.680Delete RowDelete Row1377.161377.1612
15178237AAHPG6373H3ZOCustomer 82020-21-1243268801344268801344005
Sheet1
Cell Formulas
RangeFormula
J2:J15J2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUM(IFERROR(H$2:H$15/COUNTIFS(C$2:C$15,C$2:C$15,C$2:C$15,C2,E$2:E$15,E$2:E$15,E$2:E$15,E2,N$2:N$15,N$2:N$15),0)),"Delete Row")
K2:K15K2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,IF(I2<>0,SUMIFS(I:I,C:C,C2,E:E,E2),SUMIFS(L:L,C:C,C2,E:E,E2)),"Delete Row")
 
Upvote 0

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
I did find a way to do it in a single column (only done with the first one so far). As I suspected though, it is far more complex and inefficient.

I've set this formula to the exact ranges in the sample sheet, it could be done a bit bigger as required but full columns will take ages to calculate, that is assuming that excel doesn't crash under the load. I attempted the sample with full columns and had to force close excel because it was taking to long to process.

If you want to go with this method then dynamic named ranges (or structured tables) would be most sensible way to set the correct ranges for the formula to use. If you have a lot of data (1000's of rows) then I would strongly advise sticking with the extra column.
Book1
ABCDEFGHIJKLMN
1ABTINNAMEInvoice numberCDTaxable Value (₹)IGSTCombined TaxableCombined TaxCGSTSGSTRate (%)
2152439AKXPR3359E3ZJCustomer 1IN-ZSHB-371052159.3202159.32194.34194.34194.3418
31139AALCA3377L3Z6Customer 2SMN008305200257711863.56011863.562135.441067.721067.7218
433839AALCA3377L3Z6Customer 2SMN008305200257711863.560Delete RowDelete Row1067.721067.7218
5164534AAECB3833N3ZUCustomer 3GST-53026733.51336.6826733.51336.68005
68639AACCC8357H3ZECustomer 4181/2020-2113000130011711711718
7161539ABHPC3938R3Z8Customer 5ICHABE202100050412480.5018540.341968.331123.251123.2518
8161639ABHPC3938R3Z8Customer 5ICHABE20210005046031.270Delete RowDelete Row844.37844.3728
9161739ABHPC3938R3Z8Customer 5ICHABE202100050428.570Delete RowDelete Row0.710.715
1037737AELPN4353H3ZCCustomer 6IN-462531072.88193.121072.88386.240018
116837AELPN4353H3ZCCustomer 6IN-462531072.88193.12Delete RowDelete Row0018
1261839AAJFD5433B3ZRCustomer 7KA-1176-20-2151509.52051509.521287.741287.741287.745
1378339AAJFD5433B3ZRCustomer 7KA-1274-20-212761.9025714.581446.2169.0569.055
1478439AAJFD5433B3ZRCustomer 7KA-1274-20-2122952.680Delete RowDelete Row1377.161377.1612
15178237AAHPG6373H3ZOCustomer 82020-21-1243268801344268801344005
Sheet1
Cell Formulas
RangeFormula
J2:J15J2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUM(IFERROR(H$2:H$15/COUNTIFS(C$2:C$15,C$2:C$15,C$2:C$15,C2,E$2:E$15,E$2:E$15,E$2:E$15,E2,N$2:N$15,N$2:N$15),0)),"Delete Row")
K2:K15K2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,IF(I2<>0,SUMIFS(I:I,C:C,C2,E:E,E2),SUMIFS(L:L,C:C,C2,E:E,E2)),"Delete Row")
Perfect. This is what I was talking about. My data has up to 20000 rows in some cases. With the help of this forum, I have used more complex formulas in different cases. I tried to make it as simple as possible so that I can write a code for my project easily. First formulas and then VBA code. A long way to go. Thanks JasonB75
 
Upvote 0
I did find a way to do it in a single column (only done with the first one so far). As I suspected though, it is far more complex and inefficient.

I've set this formula to the exact ranges in the sample sheet, it could be done a bit bigger as required but full columns will take ages to calculate, that is assuming that excel doesn't crash under the load. I attempted the sample with full columns and had to force close excel because it was taking to long to process.

If you want to go with this method then dynamic named ranges (or structured tables) would be most sensible way to set the correct ranges for the formula to use. If you have a lot of data (1000's of rows) then I would strongly advise sticking with the extra column.
Book1
ABCDEFGHIJKLMN
1ABTINNAMEInvoice numberCDTaxable Value (₹)IGSTCombined TaxableCombined TaxCGSTSGSTRate (%)
2152439AKXPR3359E3ZJCustomer 1IN-ZSHB-371052159.3202159.32194.34194.34194.3418
31139AALCA3377L3Z6Customer 2SMN008305200257711863.56011863.562135.441067.721067.7218
433839AALCA3377L3Z6Customer 2SMN008305200257711863.560Delete RowDelete Row1067.721067.7218
5164534AAECB3833N3ZUCustomer 3GST-53026733.51336.6826733.51336.68005
68639AACCC8357H3ZECustomer 4181/2020-2113000130011711711718
7161539ABHPC3938R3Z8Customer 5ICHABE202100050412480.5018540.341968.331123.251123.2518
8161639ABHPC3938R3Z8Customer 5ICHABE20210005046031.270Delete RowDelete Row844.37844.3728
9161739ABHPC3938R3Z8Customer 5ICHABE202100050428.570Delete RowDelete Row0.710.715
1037737AELPN4353H3ZCCustomer 6IN-462531072.88193.121072.88386.240018
116837AELPN4353H3ZCCustomer 6IN-462531072.88193.12Delete RowDelete Row0018
1261839AAJFD5433B3ZRCustomer 7KA-1176-20-2151509.52051509.521287.741287.741287.745
1378339AAJFD5433B3ZRCustomer 7KA-1274-20-212761.9025714.581446.2169.0569.055
1478439AAJFD5433B3ZRCustomer 7KA-1274-20-2122952.680Delete RowDelete Row1377.161377.1612
15178237AAHPG6373H3ZOCustomer 82020-21-1243268801344268801344005
Sheet1
Cell Formulas
RangeFormula
J2:J15J2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUM(IFERROR(H$2:H$15/COUNTIFS(C$2:C$15,C$2:C$15,C$2:C$15,C2,E$2:E$15,E$2:E$15,E$2:E$15,E2,N$2:N$15,N$2:N$15),0)),"Delete Row")
K2:K15K2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,IF(I2<>0,SUMIFS(I:I,C:C,C2,E:E,E2),SUMIFS(L:L,C:C,C2,E:E,E2)),"Delete Row")
The K2 formula needs editing as it is taking both the common values as per rate. I think I can alter that.
 
Upvote 0
Jasonb75. It's not working in the original data base. The common taxable and common tax amounts are showing 1/2 of the total amounts where the rate is the same. FYI I have changed the range in the formula. GTG. Will try again tonight.
 
Upvote 0
query to combine tax.xlsx
ABCDEFGHIJKLMNOP
1LineABCDEGROSSTAXABLEIGSTCombine TAXABLECombine CGSTCGSTSGSTRateCorrect Answer to be in JCorrect Answer to be in K
2139AKXPR1159E3ZJCustomer 1IN-ZSHB-371052548.002159.320.002159.32194.34194.34182159.32194.34
3239AALCA3177L1Z7Customer 2SMN008305200257713999.0011863.560.005931.78533.861067.721811863.561067.72
4339AALCA3177L1Z7Customer 2SMN008305200257713999.0011863.560.00Delete RowDelete Row1067.7218Delete RowDelete Row
5439AAICA3918J1ZECustomer 3ADS-2021-206811731.771467.610.001467.61132.08132.08181467.61132.08
6539AAMCA7514L1Z8Customer 4239745.00631.360.00315.6828.4156.8218631.3656.82
7639AAMCA7514L1Z8Customer 4239745.00631.360.00Delete RowDelete Row56.8218Delete RowDelete Row
8734AAECB3813N1ZUCustomer 5GST-44865244.0062136.753106.8462136.750.000.00562136.750.00
9834AAECB3813N1ZUCustomer 5GST-4647966.0045681.752284.0922840.880.000.00545681.750.00
10934AAECB3813N1ZUCustomer 5GST-4647966.0045681.752284.09Delete RowDelete Row0.005Delete RowDelete Row
111017AAHPG7373H1ZOCustomer 62020-21-124328224.0026880.001344.0026880.000.000.00526880.000.00
121117ATLPK9833D1ZKCustomer 721434965.0033300.001665.0016650.000.000.00533300.000.00
131217ATLPK9833D1ZKCustomer 721434965.0033300.001665.00Delete RowDelete Row0.005Delete RowDelete Row
141317ATLPK9833D1ZKCustomer 728432340.0030800.001540.0030800.000.000.00530800.000.00
151439AADCF1911H1ZUCustomer 81355890.005610.000.002805.0070.13140.2555610.00140.25
161539AADCF1911H1ZUCustomer 81355890.005610.000.00Delete RowDelete Row140.255Delete RowDelete Row
171639AADCF1911H1ZUCustomer 814013497.0012854.500.0012854.50321.35321.35512854.50321.35
181739AADFG7717M1ZYCustomer 9KR-POS-161236.0030.000.0030.002.702.701830.002.70
191839AADFG7717M1ZYCustomer 9KR-POS-1718608.00443.100.00443.1026.5926.5912537.1035.05
201939AADFG7717M1ZYCustomer 9KR-POS-1718608.0094.000.00Delete RowDelete Row8.4618Delete RowDelete Row
212039AADFG7717M1ZYCustomer 9KR-POS-1719759.00677.000.00677.0040.6240.6212677.0040.62
222139AADFG7717M1ZYCustomer 9KR-POS-175890.0030.000.0030.001.801.801277.006.03
232239AADFG7717M1ZYCustomer 9KR-POS-175890.0047.000.00Delete RowDelete Row4.2318Delete RowDelete Row
242339AADFG7717M1ZYCustomer 9KR-POS-21831064.00950.000.00950.0057.0057.0012950.0057.00
252439AADFG7717M1ZYCustomer 9KR-POS-2302599.00171.000.00171.0010.2610.2612516.0041.31
262539AADFG7717M1ZYCustomer 9KR-POS-2302599.00345.000.00Delete RowDelete Row31.0518Delete RowDelete Row
272639AADFG7717M1ZYCustomer 9KR-POS-25671476.001149.120.001149.1268.9568.95121309.1283.35
282739AADFG7717M1ZYCustomer 9KR-POS-25671476.00160.000.00Delete RowDelete Row14.4018Delete RowDelete Row
292839AADFG7717M1ZYCustomer 9KR-POS-2612787.002319.800.002319.80139.19139.19122479.80153.59
302939AADFG7717M1ZYCustomer 9KR-POS-2612787.00160.000.00Delete RowDelete Row14.4018Delete RowDelete Row
313039AADFG7717M1ZYCustomer 9KR-POS-27581576.001354.360.001354.3681.2681.26121404.3685.76
323139AADFG7717M1ZYCustomer 9KR-POS-27581576.0050.000.00Delete RowDelete Row4.5018Delete RowDelete Row
333217AAACH1743R1ZFCustomer 102020-21-713887091.2082944.004147.2082944.000.000.00583827.92
343334ACNPT1585G1ZBCustomer 11621043.00883.92159.11441.960.000.0018883.920.00
353434ACNPT1585G1ZBCustomer 11621043.00883.92159.11Delete RowDelete Row0.0018Delete RowDelete Row
363539AADCH8879C1Z5Customer 12AD/647554728.95617.750.00617.7555.6055.6018617.7555.60
Taxable + Tax
Cell Formulas
RangeFormula
J2:J36J2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUM(IFERROR(H$2:H$18296/COUNTIFS(C$2:C$18296,C$2:C$18296,C$2:C$18296,C2,E$2:E$18296,E$2:E$18296,E$2:E$18296,E2,N$2:N$18296,N$2:N$18296),0)),"Delete Row")
K2:K36K2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUM(IFERROR(L$2:L$18296/COUNTIFS(C$2:C$18296,C$2:C$18296,C$2:C$18296,C2,E$2:E$18296,E$2:E$18296,E$2:E$18296,E2,N$2:N$18296,N$2:N$18296),0)),"Delete Row")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
E2:E36Expression=COUNTIFS(D$2:D$18296,D2,E$2:E$18296,E2)>1textNO
 
Upvote 0
I forgot to add that you will need to array confirm the formula in the first row with Ctrl Shift Enter before filling down.
 
Upvote 0
Yo
I did find a way to do it in a single column (only done with the first one so far). As I suspected though, it is far more complex and inefficient.

I've set this formula to the exact ranges in the sample sheet, it could be done a bit bigger as required but full columns will take ages to calculate, that is assuming that excel doesn't crash under the load. I attempted the sample with full columns and had to force close excel because it was taking to long to process.

If you want to go with this method then dynamic named ranges (or structured tables) would be most sensible way to set the correct ranges for the formula to use. If you have a lot of data (1000's of rows) then I would strongly advise sticking with the extra column.
Book1
ABCDEFGHIJKLMN
1ABTINNAMEInvoice numberCDTaxable Value (₹)IGSTCombined TaxableCombined TaxCGSTSGSTRate (%)
2152439AKXPR3359E3ZJCustomer 1IN-ZSHB-371052159.3202159.32194.34194.34194.3418
31139AALCA3377L3Z6Customer 2SMN008305200257711863.56011863.562135.441067.721067.7218
433839AALCA3377L3Z6Customer 2SMN008305200257711863.560Delete RowDelete Row1067.721067.7218
5164534AAECB3833N3ZUCustomer 3GST-53026733.51336.6826733.51336.68005
68639AACCC8357H3ZECustomer 4181/2020-2113000130011711711718
7161539ABHPC3938R3Z8Customer 5ICHABE202100050412480.5018540.341968.331123.251123.2518
8161639ABHPC3938R3Z8Customer 5ICHABE20210005046031.270Delete RowDelete Row844.37844.3728
9161739ABHPC3938R3Z8Customer 5ICHABE202100050428.570Delete RowDelete Row0.710.715
1037737AELPN4353H3ZCCustomer 6IN-462531072.88193.121072.88386.240018
116837AELPN4353H3ZCCustomer 6IN-462531072.88193.12Delete RowDelete Row0018
1261839AAJFD5433B3ZRCustomer 7KA-1176-20-2151509.52051509.521287.741287.741287.745
1378339AAJFD5433B3ZRCustomer 7KA-1274-20-212761.9025714.581446.2169.0569.055
1478439AAJFD5433B3ZRCustomer 7KA-1274-20-2122952.680Delete RowDelete Row1377.161377.1612
15178237AAHPG6373H3ZOCustomer 82020-21-1243268801344268801344005
Sheet1
Cell Formulas
RangeFormula
J2:J15J2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,SUM(IFERROR(H$2:H$15/COUNTIFS(C$2:C$15,C$2:C$15,C$2:C$15,C2,E$2:E$15,E$2:E$15,E$2:E$15,E2,N$2:N$15,N$2:N$15),0)),"Delete Row")
K2:K15K2=IF(COUNTIFS(C$2:C2,C2,E$2:E2,E2)=1,IF(I2<>0,SUMIFS(I:I,C:C,C2,E:E,E2),SUMIFS(L:L,C:C,C2,E:E,E2)),"Delete Row")
You are right Jasonb. Now I understand what you tried to tell me. If it is taking so much time to calculate in these 30-40 rows, I can imagine how long will it take to calculate in 20000 rows. Till I find a better solution, I think I will go with the 4 helper columns as it is faster. Thank you so much for your time and effort.
 
Upvote 0
Even the above working formula with the helper columns is not working in the data base. Better start fresh tomorrow and call it off for today.
 
Upvote 0
As long as the format is the same it will work fine. Possibly you have one of the row / column references wrong when you've changed it to fit the database.
 
Upvote 0
As long as the format is the same it will work fine. Possibly you have one of the row / column references wrong when you've changed it to fit the database.
I have arranged the columns in the same order as in the data base. That is why I have left some blank columns so that I can copy the formula and paste it directly. There is one mismatch only to correct. Will let you know as soon I find the mistake.
 
Upvote 0

Forum statistics

Threads
1,214,527
Messages
6,120,054
Members
448,940
Latest member
mdusw

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