SUMIFS help if there is a + sign

K0st4din

Active Member
Joined
Feb 8, 2012
Messages
488
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Platform
  1. Windows
Hello, everyone,
I ask for your help to correct the formula, because I have a condition that is a little different and that's where my problem comes from.
I will attach a photo to see the columns I work with and respectively the end result, which gives me an error in adding the numbers when they are +
If we take BISO5 - the result should be = 360, but because in some places I have two words and two numbers, respectively, the end result is = 305, which is not true.
The formula I made is calculated, but when it is missing (or it is independent).
Please for some assistance how in the same table, to calculate correctly, if possible, of course!
Thank you in advance!
2021-02-18_142543.jpg
 
Consider writing to the table in two rows not trying to add them together in one.
 
Upvote 0

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Thank you very much, but this is not the solution, column P should not be touched, for no reason.
The second, which is (you may have missed it, but for example BISO5, can be = and 0, or any word).
In your help, I will always count it as 10, which is not OK!
In column P, it should be as it is at the moment of my example and the biggest problem is + !
Consider writing to the table in two rows not trying to add them together in one.
It is impossible!
 
Upvote 0
As you can see excel will ignore 10+15 in mathematical formulas. It sees them as textual. Its probably possible to write a formula but it will be cumbersome and slow. In column J is the most you ever see two items added? Or could it be any number?
 
Upvote 0
You are correct...I did miss something. I see that some codes assume different values: for example, BISO5 is sometimes 0, sometimes 10, and sometimes 25...and perhaps some other value. I assume your macro or something else determines which value should be assigned to the code names. Generally, mixing text and numeric values like those in column P is a bad idea, especially when you want to add them. If you are insistent on leaving column P untouched and keeping both text and numbers in that column, then you need some other way to convert the text to numbers so that they can be added. One approach then is to establish a helper column to do the conversion and summing of the values represented by column P. In this case, I clicked on cell Q2 and then opened the Define Name window to create a Named Range. I called this range myParray and in the field labelled "Refers to:", I entered
=EVALUATE( "{" & SUBSTITUTE(Sheet1!$P2,"+",",") & "}" )
This expression changes the plus signs (+) to commas (,) and builds something resembling an array...which Excel then will treat as an array when myParray is called.
Note that the cell reference locks only the P column with the $ sign, while the row reference floats. This means that as the formula using this myParray reference is copied down the worksheet, the myParray array will dynamically adjust to refer to the corresponding content on the same row in the adjacent column P.

Then your original formula can be used with minor changes, referring to column Q for the sums rather than column P.

test bro.xlsm
BCDJPQANAOAPAQARAS
1namedatekkkpointsumpoints4/1/202010/30/2020namemostriprobro
2Dave Toni5/19/2020RUS101515Dave Toni0MOXI50
3Dave Toni10/20/2020BISO51010Dave Toni0MOXI70
4Dave Toni10/20/2020RUS101515Dave Toni0LEV50
5Dave Toni10/6/2020BISO51010Dave Toni0LEV70
6Dave Toni9/21/2020BISO51010Dave Toni170AMLF108
7Dave Toni8/17/2020BISO5+AMLF1010+1525Dave Toni9AMLF53
8Dave Toni5/11/2020RUS101515Dave Toni0AMOL5/400
9Dave Toni5/20/2020RUS101515Dave Toni0AMV5/1600
10Dave Toni7/2/2020BISO51010Dave Toni455BISO536
11Dave Toni10/5/2020BISO51010Dave Toni0CANDF160
12Dave Toni10/5/2020RUS101515Dave Toni0CLOP0
13Dave Toni9/30/2020BISO51010Dave Toni0COXI2000
14Dave Toni10/7/2020BISO500Dave Toni0DOXA20
15Dave Toni10/6/2020RUS101515Dave Toni0DOXA40
16Dave Toni9/16/2020BISO51010Dave Toni0IND1.5SR0
17Dave Toni10/22/2020RUS101515Dave Toni0IRB1500
18Dave Toni8/4/2020BISO5+AMLF1010+1525Dave Toni0IRB3000
19Dave Toni5/19/2020BISO51010Dave Toni0LERC100
20Dave Toni7/20/2020BISO51010Dave Toni0LOSF50/12.50
21Dave Toni9/17/2020RUS101515Dave Toni0NEBIF50
22Dave Toni8/19/2020BISO51010Dave Toni340RUS1023
23Dave Toni5/15/2020BISO51010Dave Toni0VALCO160/12.50
24Dave Toni10/29/2020BISO51010Dave Toni0VALF1600
25Dave Toni9/4/2020RUS101515
26Dave Toni7/1/2020BISO51010
27Dave Toni10/2/2020BISO51010
28Dave Toni10/28/2020BISO51010
29Dave Toni10/8/2020RUS101515
30Dave Toni10/2/2020BISO51010
31Dave Toni9/17/2020RUS101515
32Dave Toni9/28/2020BISO51010
33Dave Toni10/27/2020AMLF101515
34Dave Toni10/27/2020BISO51010
35Dave Toni7/7/2020BISO51010
36Dave Toni6/15/2020BISO52525
37Dave Toni9/4/2020RUS101515
38Dave Toni6/12/2020RUS101515
39Dave Toni9/21/2020RUS101515
40Dave Toni8/4/2020BISO51010
41Dave Toni9/16/2020BISO51010
42Dave Toni6/24/2020AMLF533
43Dave Toni9/9/2020AMLF533
44Dave Toni6/23/2020BISO51010
45Dave Toni7/29/2020BISO5+AMLF1010+1525
46Dave Toni7/21/2020BISO5+AMLF1010+1525
47Dave Toni6/5/2020BISO51010
48Dave Toni9/15/2020RUS101515
49Dave Toni10/21/2020RUS101515
50Dave Toni7/21/2020BISO5+AMLF1010+1525
51Dave Toni6/15/2020RUS101515
52Dave Toni10/26/2020RUS1000
53Dave Toni9/15/2020AMLF101515
54Dave Toni10/8/2020AMLF101515
55Dave Toni10/9/2020BISO51010
56Dave Toni10/9/2020RUS101515
57Dave Toni5/21/2020BISO51010
58Dave Toni6/12/2020BISO5+RUS1010+1525
59Dave Toni9/9/2020AMLF533
60Dave Toni9/8/2020BISO51010
61Dave Toni7/2/2020RUS101515
62Dave Toni8/13/2020BISO51010
63Dave Toni10/2/2020RUS101515
64Dave Toni9/17/2020RUS101515
65Dave Toni10/14/2020BISO51010
Sheet1
Cell Formulas
RangeFormula
AQ2:AQ24AQ2=IF(AR2="","",SUMIFS($Q$2:Q$65536,$D$2:$D$65536,">="&$AN$1,$D$2:$D$65536,"<="&$AO$1,$B$2:$B$65536,$AP2,$J$2:$J$65536,"*"&$AR2&"*"))
AS2:AS24AS2=IF($AR2="","",COUNTIFS($J$2:$J$65536,"*"&$AR2&"*",$B$2:$B$65536,$AP2,$D$2:$D$65536,">="&$AN$1,$D$2:$D$65536,"<="&$AO$1))
Q2:Q65Q2=SUM(myParray)
Cells with Data Validation
CellAllowCriteria
J2:K65Any value
 
Upvote 0
From my understanding where BISO5+AMLF10 is in a cell and the corresponding cell has 10+15 then BISO5 = 10 and AMLF10 = 15.
 
Upvote 0
You're right. I misinterpreted the example in post #1...please disregard my post #14. In post #1, I believe BISO5 for the date range and name described should yield a total of 365, not 360. So two text strings (the code names separated by + symbols and their corresponding values also separated by + symbols) need to be split and then only the one corresponding to the queried code name needs to be extracted. I'll have to give this some more thought.
 
Upvote 0
I believe BISO5 for the date range and name described should yield a total of 365, not 360
No, no

First, for some unintentional reason, line number 36 - BISO5 must be changed to 10, not 25.
I will try to describe all the results that should come out as information: according to the date that is chosen
BISO5 - 350
RUS10 - 330
AMLF10 - 120
This is for the example itself
 
Upvote 0
As you can see excel will ignore 10+15 in mathematical formulas. It sees them as textual. Its probably possible to write a formula but it will be cumbersome and slow. In column J is the most you ever see two items added? Or could it be any number?
This is just a small example with a few words, I have over 250 such words, with strictly defined points (which can be the same, ie for different words the same points or 0).
This table has been made and formulas and macros have been added for years and so far it is not confused in my accounts and everything is 1,000,000% correct. But since I started to get quite annoyed to filter over 250 times, I decided to make a sample for each word, which would give me the finished points.
In this line of thinking, if at all possible, I will have to upgrade without changing the current columns, in which everything works flawlessly!
 
Upvote 0
You would be well advised to create a sheet where the summation is possible with native formulas if you want to do summation on the sheet. It would be relatively easy to write code to extract the results but of course then they arent 'live' formulas but static results that need to be refreshed by rerunning the code. Not a good way to run a changing spreadsheet.
 
Upvote 0
I completely agree with comments from @steve the fish. The current table structure does not lend itself well to summarizing the data in the manner requested. The most significant issues are caused by combining two or more data points into a cell. Taking row 45 as an example:
Dave Toni
7/29/2020​
BISO5+AMLF10​
10+15​

Text strings describing multiple category codes are shown in a single cell separated by plus signs (+). Their associated values are shown in an adjacent cell also separated by plus signs. To perform the desired summary, these text strings need to be examined to determine whether the queried category is included, and if so, then the relative position within the items is noted so that the corresponding quantity can be extracted and included in an array formed from similar results for each of the rows in the data table. I don't see any practical way to accomplish this. I developed a formula that creates an array showing the queried item position within each categories field (e.g., if "AMLF10" were desired, the above row would yield a 2), but this array needs to be used to extract the text in the value(s) field in that same position (giving a 15), and this becomes very unwieldy.

If instead the main data table were structured so that those rows containing combined category code/value data points were split and entered on separate rows like this:
ABCDave Toni
7/29/2020​
BISO5​
10​
ABCDave Toni
7/29/2020​
AMLF10​
15​
...then a solution would be trivial. Note that I've added a common reference field in the first column to relate these two rows to each other since they are both apparently tied together somehow. Conceptually, the information is still the same, but this table structure would be much easier to operate on.

If the table structure cannot be altered, then I would recommend investigating two other options: 1) develop a VBA solution, and 2) consider adding a number of helper columns (full table length with a sufficient number of columns to extract the multiple category codes and values into separate columns). Regarding this second idea, what is the largest number of category codes that would be found in a cell? And are you amenable to having helper cells in the table?
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

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