Sum of Questionnaire Scores Based on a Domain Table - excel

I have created a questionnaire that consists of around 100 questions. Participants are asked to fill them in online, where the items are shuffled each time. These items are separated into 6 domains where, for the sake of easier understanding, let's just call them Domain 1 - 6.
I have them typed in one specific table called "Correspondence", with format like below:
(An example)
Question No.|Domain
   1  |Domain A
   2  |Domain C
   3  |Domain A
   4  |Domain B
   5  |Domain A
   6  |Domain C
I used Google Form to generate a spreadsheet of RAW data of respondents, where it will help me mark the RAW Scores, for each item on a separate column:
(An example)
Submission ID|Question 1|Question 2|Question 3|Question 4|Question
5|Question 6
Participant 1 |  2  |  3  |  5   |  1   |  2   |  4   |
Participant 2 |  5  |  4  |  5   |  3   |  5   |  1   |
Participant 3 |  1  |  1  |  1   |  2   |  2   |  2   |
The next thing I need to do is generate another table that sums up the Domain totals for each participant. So from the example above, I need to sum 1,3,5 as Domain A, 4 as Domain B and 2 & 6 as Domain C:
(An example)
Participant 1
    |Domain A|Domain B|Domain C|
Total |  9  |  1  |  7   |
The hardest thing is to find a proper method to kick start this process. Can anyone point me in the right direction? Either formulas or VBAs would be fine too. Thanks!

This can be done if you are able to create a helper row.
First, I created a table to link the question to domain. That is named in my example as "Correspondence". This table is somewhat the answer key. From your description of the problem, you need a table like this to establish which question is associated with the domain/category/point system you want to use.
I then created a helper row for the survey results shown on row 9. This has =INDEX($B$3:$C$8,MATCH(B$10,$B$3:$B$8,0),2) in cell B9 as the code to reference the question to the domain. This is immediately above the questions in the example, but you can put it on a separate sheet if needed.
Then you can just sum them up.
=SUMPRODUCT(SUMIFS(INDIRECT(MATCH($E3,$A:$A,0)&":"&MATCH($E3,$A:$A,0)),$9:$9,F$2))
This formula uses MATCH, which returns an integer, inside INDIRECT to be used as a dynamic row reference. This will fail if the participant names are not unique. The SUMIFS inside the SUMPRODUCT allows the row to be treated like an array without using an array formula. So you can recreate the example I have and copy/paste or drag and paste the formulas as you wish.
A different approach may be that you want to sum up the points to the questions first and then do the conversion from question to domain. That way you don't ever have to manipulate the raw data, just the reports. That may be the better approach for you, actually.
Edit: Added information about the formulas and the example.

Related

Returning list of projects that are assigned to a person

I’m creating a project management template and I’ve bumped into problem.
I need to return a list of projects to 1 cell assigned to a certain member in a given time period (does project falls in a period or not).
When retrieving project names that are assigned to certain person in a period there is a problem because the range of cells that contains information of enrolled members includes several codes in text form - XX, YZ etc. F:F. Cells that include information about code assembled from 3 columns(based on the type of engagement) that could contain same person several times, cells that in that 3 columns also could contain several codes.
Ive managed to make a formula that retrieves list of projects based on starting date H:H, and deadline I:I in 1 cell:
No luck though with implementing binding to certain members. I’ve tried using another IF cycle:
{=TEXTJOIN(“; “;TRUE;IF($H$3:$H$13<=D$19;IF($I$3:$I$13>=C$19;IF($F3:$F$13=“*XX*”;$A$3:$A$13;””);””);””))}
Result - empty cell
I’ve tried implementing VLOOKUP and COUNTIF but so far unsuccessfully
I would really appreciate any possible solutions or workarounds, thanks
I think you can use a filter function to get this. I used an example on this google sheet, but it should work exactly the same in Excel. Basically you want to textjoin an array which you filter by meeting multiple and statements (*) along with one OR condition (shown with pluses) over four columns.
Double check the columns and ranges, but I think this works.
=TEXTJOIN(";",TRUE,FILTER($A$3:$A$19,
($H$3:$H$19<=$D$19) * ($I$3:$I$19>=$C$19) * (
(isnumber(find($B20,$D$3:$D$19))+
(isnumber(find($B20,$E$3:$E$19)))+
(isnumber(find($B20,$F$3:$F$19)))+
(isnumber(find($B20,$G$3:$G$19))) ))))

Lookup several keywords in a column, if found, return 4 columns

I've got two databases, one with 11,000 entries, and another that I've narrowed down to around 600. They are databases with Company name, and contact information for people at that company. So column A - Company Name. Column B - last name, column C - first name, column D - position, and column E - email address. What I'd like to do is search column D - position for several keywords - vice, benefit, resource, and if found, return the four columns - last name, first name, position and email address. So for company name X, we might have 10 contact names, and a couple may have contact info for people that fall into those keywords. I'd like to return those specific people.
I've managed to get the formatting between the company names normalized between the two lists, using brute force, and some index matching formulas (that was fun!), so those are the same, and I could probably do something like add 5 or 6 rows after each unique company name to accommodate the potential number of contacts we might have for each company, but I have no idea how to return multiple specific cells for a keyword search.
I think something like this might work -
=index(columntoreturn, small(if(isnumber(search(keywords, columntosearch)), match(row(column), row(column))), rows(array)))
But that will only return an individual cell, rather than the four I would need.
Here's an example of the two databases I'm working with.
as you asked the same have been closed as answered thorugh comment behalf of #Scott Craner
Answer
As I stated in my first comment, Advanced Filter is designed for this. You can put code to automatically do it based on certain cells on the page changing values. A formula is not ideal in that it would require it to be an array formula and the more array formulas and the larger the dataset would bog down the calc times. See here for an example on how to set up advanced filter using vba.

Making a Top 3 column based on a column category with answers in the row

I'm managing the server awards for a gaming community and using Google Forms for the first time. The voting phase ended, I moved the form responses into an excel sheet in Google Docs.
It goes like this (Answers from 89 forum accounts [ROWS] for 31 questions [COLUMNS])
(https://i.imgur.com/w9ICMjv.png)
The nominations were put as multiple-choice votes in the Forms as can be seen here, if this helps at all.
(https://i.imgur.com/4OQxiKH.png)
Most of the attempts I've read on the internet read back to integer values, whereas I'm using strings. Plus, I really have no idea how to work formulas on Excel.
I need the results to be like this, if possible.
Name One —> Most repeated name in Column C, from Row 2 to Row 30.
(47) —> Amount of times Name One is repeated in Column C.
Name Two and Three show us the second and third most repeated names.
(https://i.imgur.com/EkocuoG.png)
If you are using Google Sheets
To get your top three in column C, add this formula into another sheet.
=QUERY('Your sheet name'!A1:Z100,
// Change the sheet name and the last cell reference to suit.
// Keep the single quotes around the sheet name if it has a
// space or a non-alphanumeric character in it.
"Select C, count(C) group by C order by count(C) desc limit 3")
Thanks to #pnuts's answer on another question for allowing me to double check without turning on my laptop. :)
Have tested it and it's working for me.

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.

Excel: How to parse/cast text as a formula?

Is it possible to parse/cast text (like "=A1+A2") as a formula in MS Excel? I want to build a formula from pieces of text - some of which will only be typed in later by a user.
If the INDIRECT() function did not only work for referencing cells, then I could have typed this =INDIRECT("=A1+A2").
I know you can a work around this problem by simply adding a lot more hidden columns to do sub calculations. But for the sake scalability and efficiency, I would rather do something like the above.
I found a similar questions here and here, yet they don't solve my problem.
The Real-world problem:
Read on for a better understanding as to why you would want to do the above
Scenario
Each item in the list consists of a string, which contains anywhere from 1 to 5 account names each. Each account name is followed by an account number in brackets. The length of the number determines the type of account. Part of the account number is a date, of which the date format depends on the type of account. Further more, each account type may have more that 1 account-number length associated with it, although each number-length[*] is only associated with 1 account type.
Objectives
Extract account-names and their respective account-numbers and account-types from a list.
Make an assumption as to the account-type from the account-number
Validate this assumption by inspecting the build of the number and elements in the name
Check the validity of the account-numbers depending on their type.
The tricky part (this is where my problem lies)
The account-types and their respective account-number-lengths are not known before hand, and are typed into a table by the user of the sheet, specifying a type of account and the number-lengths associated with this account-type. The user should type this into a list - not go and tinker around with delicate formulas
Done so far
Column A: Contains the raw data (each cell has up to 5 names and numbers)
Columns B..F: Each column extracts 1 name, remains empty if all are already extracted
Columns G..K: Each column extracts 1 number corresponding to its name in columns B..F, remains empty if all are already extracted
Columns L..P: Each column calculates the length of the corresponding number in columns
G..K
Now the user would type the following details into a table which assigns certain number-lengths an account type:
TYPE2, BUSINESS, (OR(length=13,length=6))
where length will later be replaced with the cell address which contains the calculated account number-length.
What I want to do now
Columns Q..U:
Should all indicate the account-type of the corresponding account-number in columns G..K. The idea is to build a nested if-elseIf-elseIf formula using the criteria typed in by the user as specified above. Example of one of the elseIF statements:
SUBSTITUTE(CONCATENATE("=IF(",criteria,",",type,",",errCode)),"length","O10"))
All of these elseIf statements will then be concatenated together to form a master formula which will then need to be parsed/cast as a formula to calculate the account-type
This proposal uses only 5 columns (1 for each account-number, containing the master formula) and a table specifying account-types and criteria, also keeping the user away from formulas. Editing 1 line of code (the criteria) will update all formulas. Efficient & Scalable.
Since the user should never tinker around with the formulas under the hood, a simple 1 column if-elseIf-elseIf is out of the question. The alternative to the above would be to make a separate column to test for each account-type for each account-number. Separating/Abstracting out each test to its own column results in much better readability, easier editing & much less debugging - Unless you like multi-screen-wide-formulas. Example: 5 account-numbers * 10 possible account types = 50 extra columns.
Each edit to any criteria needs to copied to 4 other non-adjacent columns and drag-filled down 10,000 rows (columns can not be adjacent since it is effectively a 5x5 array of columns). Not Efficient nor scalable. Unless I'm missing some elegant way of updating non-adjacent formulas in a single click
The rest of the validations error indications are trivial.
Sample data
Tshepo Trust (6901/2005) Marlene Mead (8602250646085)
Great Force Inv 67 Pty Ltd (200602258007)
Jane (870811) Livingstone (6901/2005) Janette Appel (8503250647056) James (900111)
I know all this would probably be much easier to achieve with clever usage of VBA, eliminating all the need to simulate abstraction, encapsulation, multi-dimensional arrays and functional programming on a spreadsheet. But until I can program in VBA, worksheet formulas will be my refuge.
[*]: account number-length could also be described as the amount of digits in the number or as indicated by this formula: LEN(accNumber)
In VBA you have access to Cell.Formula.
I usually used Range to peek a cell by address.
I'm not sure if this would answer your question(it's a very detailed question!), but if your user was entering the account numbers in a table (I'm calling it 'RefTable') , that was:
Length of account number | business type
----------------------------------------
6 | Accountant
8 | Advisor
Then you could just use a vlookup on the length of the account number, given you've already separated them out.
=vlookup(len(accNumber), Reftable, 2, false)
Make sure that you either use a dynamic range name, or specify plenty of space below in RefTable, so that when your users add types, they don't get lost.
Also, if you have two different accounts with the same length, this could get you into trouble.

Resources