SUMIF with Index and multiple match criteria with Dynamic range - excel-formula

enter image description here
In the above problem, I am trying to create a dashboard of Brands Category wise.
The formula i am trying is. THis is in google sheets.
=INDEX($A$1:$F6,ArrayFormula(MATCH(A$12&B12,$A$1:$A6&$B$1:$B6,0)),Match(to_text(C$11),$A$2:$F$2,0))
THis returns only 1 value . But I would like to get a sum of BrandA, Catgory1 both in Nos and Pcs. How do I go about doing it? Somehow, not able to work with SUMIF. what is best suited?
Actually trying to create a dashboard for Month wise Sales/Purchase data like the link below. Any better way of doing in?
https://docs.google.com/spreadsheets/d/1047uWOrOqkW3L_1hoKh-MaY-O0_CZC0WiqmV8HZqk6o/edit?usp=sharing

Raj, if I understand your question, the following formula might provide the result you want.
=QUERY(Data!A1:F,"select A,B,sum(D),sum(E),sum(F)
where A<>'' group by A,B order by A,B
label sum(D) 'Apr',sum(E) 'May',sum(F) 'June' ",1)
This queries your data, groups it (and sorts) by brand and category (ignoring the Unit type) and sums the values. It also modifies the header text for the three summed columns.

Related

Return Column Index for Each Matching Value in a Row?

Excel Novice using Excel for Business (Online) here.
I am having a difficult time wrapping my head around a way to write a function that does three things for me.
Check a specific row of data in a large table, preferably matching ID's between the two tables (I've been using XLOOKUP to ensure that results are keyed to a specific ID)
Find and return the Column index for every cell within the row with the string "Yes"
SUM associated points tied to the column indexes.
I am creating a new QA Scoring system, and all of the questions share the potential for "Yes" and "No" but depending on the question the number of points will be different. I have been approaching this with the idea that I could return the column indexes, convert them to the points associated to the column indexes, and then SUM them for a score, but I am open to different ideas.
Click Here for a Demo of what I am trying to do, included is the actual data set I was using.
Possible Points
=SUMIFS($O$2:$AH$2,INDEX(Raw_Data!D:W,MATCH(Scoring!A4,Raw_Data!A:A,0),0),"*")
Points Earned
=SUMIFS($O$2:$AH$2,INDEX(Raw_Data!D:W,MATCH(Scoring!A4,Raw_Data!A:A,0),0),"Yes")
These will work with your present setup, but in the long run it would probably be best to just add Possible Points and Points Earned columns to your Table3, if possible.

How do I sum all the columns with the same header into one column in excel?

I am using a football dataset where I have changed all the countries to specific geographical areas in their column headers. What I want to do is I want to add up all the columns with the same geographic value with all the values added up.
This is how my data looks like:
The value of #players should still remain the same after condensing the data. I tried using the data function, but I could not figure it out.
My output should ideally look like a column with all the EUs added up, the AFRs added up etc.
It's actually unclear as to exactly what it is you're trying to do.
Here is an example use of SUMIF that addresses one possible interpretation:
=SUMIF($B$1:$E$1,F$1,$B2:$E2)
And here is an image showing how and were that formula would be used in this sample table:
If this doesn't address what you're aimed for, could you make an effort to do as I have done and show a small sample with the expected results.
I was able to solve it using the SUM function.
I used SUM(C2,C6,C7....) every column that had an EU in it and did the same for the other headers.

Outputting text values

I am unsure Excel would be able to do this automatically. I hope it can but maybe not.
I am trying to work with another member of staff in a different building. I have created a table trying to identify where the flow of some of the work is coming from. I am looking to try and count the amount of instances of text within a column. The problem is that the text can be pretty dynamic. As an example:
Consultant
a
a
b
a
b
a
b
z
c
c
c
Is there a way I can get excel to count the instances of text within the column, then create a table with the totals of the counts in it with labels.
I looked at pivot tables and that didn't seem to want to play ball.
The simplest way to do this is using COUINTIF
=COUNTIF(A:A,"a")
Which will simply tell you how many times "a" appears in the Column A.
You could easily duplicate this for every letter of the alphabet. Then use a summary table to display the results.

Excel to auto-remove duplicates before sum in CSV based on URL-paramter

I am using Really Simple Traffic Logger to store Date, Timestamp, IP and visited site by users on my website. Each user visiting the website is assigned a UID by a parameter in the URL in the form of:
http://www.domain.com/site.php?=dTM_c1_uid7
dTM = customer,
c1 = category 1,
uid7 = uid for person 7
The csv file stored contains the following:
"DATE","TIME","IP","LOOKING_FOR"
"2016-05-22","07:30:40","XX.XX.XX.XX","/site.php?=dTM_c1_uid7"
"2016-05-22","07:31:10","XX.XX.XX.XX","/site.php?=dTM_c1_uid7"
"2016-05-22","07:31:19","XX.XX.XX.XX","/site.php?=dTM_c1_uid8"
the information is stored in a CSV-file, where I am attempting to sum the results of the data, which is to be visualized by another script in real-time. However, as many of the visitors are the same people visiting the website more than once, I would like to remove these based on the UID parameter in the URL, before calculating the sum, so each count (hit) can be calculated as unique hits.
I am therefore trying to work out a formula for auto-removing duplicates that contains the "_uid7" parameter, before calculating the sum.
Is there a smart method for constructing a formula in excel that can do that automatically?
Thank you.
Supposing your data starts from A1 Please post the following formula in B1and fill down the column B with data in column A
=TRIM(SUBSTITUTE(MID(A1,(SEARCH("dTM_c1_",A1,1)+7),99),CHAR(34),REPT(CHAR(32),99)))
You will get uid7, uid8 etc which can be counted or other processing can be done.
EDIT
Based on your comments and taking "dTM_c1_uidnn.." string counts of occurrence is shown in the following snapshots. I have shown two snap shots out of which one hides the helper column.
This is the best I could do at the moment. Column B can be filtered either with Excel native Remove Duplicates OR by a VBA routine. Finding unique values of numerical values is comparatively easy using Frequency Function But somehow after repeated attempts despite following some tutorials, I could not get the desired results for text strings. I would appreciate your feedback positive or negative. My efforts would continue to find the most optimal solution.

SUMIFS with intermediate VLOOKUP in the criteria

I have 3 tables, 1 of which I want to fill in columns with data based on the other 2. Tables are roughly structured as follows:
Table 1 (Semi-Static Data)
SubGroup Group
----------- -----------
subgroup(1) group(a)
subgroup(2) group(b)
subgroup(3) group(b)
subgroup(4) group(c)
etc.
Table 2 (Variable Data)
SubGroup DataValue
----------- -----------
subgroup(1) datavalue(i)
subgroup(2) datavalue(ii)
subgroup(3) datavalue(iii)
subgroup(4) datavalue(iv)
etc.
Table 3 (Results)
Group TotalValue
----------- -----------
group(a) totalvalue(m)
group(b) totalvalue(n)
group(c) totalvalue(o)
etc.
Where the TotalValue is the sum of all DataValue's for all subgroups that belong to that particular Group.
e.g. for group(b) ---> totalvalue(n) = datavalue(ii) + datavalue(iii)
I am looking to achieve this calculation without adding any additional columns to the Data tables nor using VBA.
Basically I need to perform a COUNTIFS where there is an additional VLOOKUP matching the subgroup criteria range to the group it belongs to, and then only summing for datavalue's that match the group being evaluated. I have tried using array formulas but I'm having issues making it work. Any assistance would be very appreciated. Thank you,
EDIT: Wanted to add some details surrounding my question. First all Google searches did not provide a suitable answer. All the links had solutions to a slightly different problem were the VLOOKUP term is not dependent on the SUMIFS criteria but rather another single static variable. Stack Overflow offered similar solutions. Please let me know if anymore details are required to make my post suitable for this forum. Thank you again.
You can use the SUMPRODUCT function to do it all at once. The first reference $B$2:$B$5 is for the Group names, the second reference $E$2:$E$5 is for the datavalues. The G2 reference is for the group names in the third table, you can enter this formula for the first reference and then drag and fill for the rest.
=SUMPRODUCT($E$2:$E$5 * (G2 = $B$2:$B$5))
Some cell references, and sample data, would be helpful but something like this might be what you want:
=SUMIF(C:C,"="&INDEX(A:A,MATCH(E5,B:B,0)),D:D)
WADR & IMHO, this is simply bad worksheet design. For lack of a single cross-reference column in Table2, any solution would have to be a VBA User Defined Formula or an overly complicated array formula (the latter of which I am not even sure is possible). The data tables are not normalized database tables you can INNER JOIN or GROUP BY ... HAVING.
The formula you are trying to achieve is akin to,
=SUMPRODUCT(SUMIF(D:D, {"subgroup(2)","subgroup(3)"}, E:E))
That only works with hard-coded values as arrayed constants (e.g. {"subgroup(2)","subgroup(3)"}). I know of no way to spit a dynamic list back into the formula using additional native Excel functions but VBA offers some possibilities.
HOWEVER,
The simple addition of one more column to Table2 with a very basic VLOOKUP reduces all of your problems to a SUMIF.
     
The formula in the new column D, row 2 is,
=VLOOKUP(E2, A:B, 2, FALSE)
The formula in I2 is,
=SUMIF(D:D, H2,F:F )
Fill each down as necessary. Sorry if that is not what you wanted to hear.
Thank you everyone that responded and reviewed this post. I have managed to resolve this using an array formula and some matrix algebra. Please note that I am not using VLOOKUP (this operator cannot be performed on arrays) nor SUMIFS as my title states.
My final formula looks like this:
{=SUM(IF([Table2.xlsx]Sheet1!SubGroup=TRANSPOSE(IF([Table1.xlsx]Sheet1!Group=G2,[Table1.xlsx]Sheet1!SubGroup,"")),[Table2.xlsx]Sheet1!DataValue))}
Very simply, I create an array variable that compares the Group being evaluated (e.g. cell G2) with the Groups column for Table 1 and outputs the corresponding matching SubGroups. This results in an array with as many rows as Table 1 had (N) and 1 column: Nx1. I then transpose that array (1xN) and compare it to the SubGroups column (Mx1, M being the number of rows in Table 2) and output the DataValues column for the rows that have a corresponding SubGroup (MxN). Then I perform a sum of the whole array to return a single value.
Notice that as I didn't include a value_if_false output return on either IF operators, it will just populate with FALSE in the arrays were the conditions are not met. This does not matter though for the final result. In the first IF, FALSE will not match the SubGroups so will be ignored. For the second all values FALSE passed to SUM will be calculated as 0. The more complicated question is that it grows the amount of memory required to process as we are not filtering to just have the values we want.
For this application I decided against filtering the subarray as the trade-off in resource utilization was acceptable. If the data sets were any bigger though, I would definitely try doing it. Another concern was that I did not understand fully the filtering logic that I was using based on http://exceltactics.com/make-filtered-list-sub-arrays-excel-using-small/ so decided to simplify. Will revisit this concept latter as I think it will work. I might have completed this solution but was missing transposing the array to compare properly so abandoned this route.

Resources