Counting across several survey questions - spss

I am working with survey data and have been stuck on an issue for several hours that i am not sure how to resolve.
Respondents in my survey, were asked how frequently they had been involved in negative situations at their work place. Now, this was asked in three different questions as
(1) How frequently have you had negative experiences with your boss?
(2) ... with colleagues
(3) ... clients
Possible answers for each questions were one of the following (1) daily, (2) several times a week, (3) once a week, (4) several times each month, (5) once a month, (6) less than once a month, (7) never and (8) would prefer not to answer.
What I would like to do:
I want to count how many of my respondents that have answered between (1) - (5), (6) - (7) and (8) as missing.
Importantly, I would like to know how many unique people that have been involved in negative situations. That is, as long as you have selected between (1) - (5) for any of the answers, I would like to count that as one (If you have selected between (1) - (5) for all three or two of the questions, it should still be counted as one). Also, how many that have selected between (6) - (7) must be counted in the same manner. 8 should be counted as missing.
Do any of you know how I can resolve this? Been stuck on this for a long time now!
Hoping for answers.

You can use the syntax below. I have named your three variables Boss, Colleague and Client. Copy the syntax into a syntax file in SPSS, change the variable names appropriately and run the syntax.
**This syntax will creates five new variables from initiall Boss Colleague and Client variables.
*The first three variables will recode the three variables based on if they are 1-5=1; 6-7=2 and 8=0.
*The last two variables Harrassed_15 checks if each case has 1-5 in at least one of the first three variables.
The variables Harrassed_67 checkes if each case has at least 6-7.
RECODE Boss Colleague Client (1 thru 5 = 1) (6 thru 7 = 2) (8 = 0)
INTO Boss_Grouped Colleague_Grouped Client_Grouped.
VALUE LABELS Boss_Grouped Colleague_Grouped Client_Grouped 1 '1-5' 2 '6-7' 8 'Missing'.
FREQUENCIES Boss_Grouped Colleague_Grouped Client_Grouped.
TEMPORARY.
COUNT Harrassed_15=Boss_Grouped Colleague_Grouped Client_Grouped(1).
COUNT Harrassed_67=Boss_Grouped Colleague_Grouped Client_Grouped(2).
FREQUENCIES Harrassed_15 Harrassed_67.
COMPUTE Harrassed_15 = (((Boss_Grouped=1) + (Colleague_Grouped=1) + (Client_Grouped=1))>0).
COMPUTE Harrassed_67 = (((Boss_Grouped=2) + (Colleague_Grouped=2) + (Client_Grouped=2))>0).
FREQUENCIES Harrassed_15 Harrassed_67.
*Alternatively.
*This is alternative to above. Creates only two variables without showing how many belonged to each group.
*It produces same results.
*If you don't want to produce additional variables in your dataset then remove the TEMP.
TEMPORARY.
COMPUTE Harrassed_15 = (((Boss<=5) + (Colleague<=5) + (Client<=5))>0).
COMPUTE Harrassed_67 = ((((Boss=6) OR (Boss=7)) + ((Colleague=6) OR (Colleague=7)) + ((Client=6) OR (Client=7)))>0).
FREQUENCIES Harrassed_15 Harrassed_67.

Related

Tableau question: How to link a reference table to a dynamic calculated field value (which is an integer)? I'm assigning P values

Since Tableau does not have a function for P-values(correct me if I'm wrong here) I created a spreadsheet with all possible sample sizes under two different alphas/significance levels and need to connect the appropriate p-value to a calculated field from the main database source (aggregate count of people). I assumed I could easily match numbers with a condition to bring back the p-value in a calculated field yet I'm hitting a brick wall. Biggest issue seems to be that the field I want to join the P-value reference table to is an aggregated integer. Also, I do not have any extensions and my end result needs to be an integer, not a graph.
Any secret tricks here?
Seems I cannot blend the reference table in nor join it to an aggregate?
Thanks!
I found a work around in calculating the critical value for a two tailed t-test in tableau. However, I didn't figure out how to join based on an aggregated calculated field. Work around: I used a conditional statement just copying and pasting about 100 critical values based on (sample size - 2) aka degrees of freedom, into a calculated field. To save time, use excel to pull down the conditions to 120. Worked like a charm!
Here is the conditional logic for alpha = .2 (80%) in two tailed t-test (replace the ## line with about 117 rows):
IF [degrees of freedom] = 1 THEN 3.08
ELSEIF [degrees of freedom] = 2 THEN 1.89
ELSEIF [degrees of freedom] = 3 THEN 1.64
##ELSEIF [...calculate down to 120] = ... then ...
ELSEIF [degrees of freedom] > 121 THEN 1.28
END

Filter based on Unique Values that only match certain criteria

This may be beyond my skill level in Google Sheets, and it's certainly straining my brain to think through, but I have two columns out a large spreadsheet (30000 lines or so) that I need to find matches between unique values on one list, and non-unique but specific values ONLY on another list. That is, I would need the following list to return only the values on the left that had a 3 in the right column every time that value appears on the left, not just for a specific instance.
"Unique" Identifier (can repeat)
Value
1
2
2
3
3
2
4
2
5
3
6
2
1
2
2
2
3
2
4
2
5
2
6
2
I have the following formula from another couple answers mocked up, but it doesn't get me all the way there:=UNIQUE(FILTER(A2:A,B2:B>0))
How can I get it to exclude the ones that have, for instance, both a 2 and a 3 in the right column for the same value in the left column?
Edit: To put it in more real terms (I was trying to keep it abstract so I could understand the basics), I have a Catalog ID and a Condition for items, and need to find all Catalog IDs that only have Good copies, not any Very Good copies. This link should show what I want to achieve:
https://docs.google.com/spreadsheets/d/e/2PACX-1vSjenkDS2Mk3t4kTcDoJqSc8AV6ONu4Q17K1HPaIUdJkb7dhdnbAt-CzUxGO3ZoJISNpGajUtFTGz8c/pubhtml?gid=0&single=true
to return only the values on the left that had a 3 in the right column every time
try:
=UNIQUE(FILTER(A:A; B:B=3))
update 1:
=UNIQUE(FILTER(Sheet1!A:A; Sheet1!B:B="Good"))
update 2:
=UNIQUE(FILTER(Sheet1!A:A, Sheet1!B:B="Good",
NOT(COUNTIF(FILTER(Sheet1!A:A, Sheet1!B:B<>"Good"), Sheet1!A:A))))

How to sum up arrays to then find the minimum

Here's my problem: I have 2 sheets in my document (lets call them Sheet 1 and Sheet 2). They contain similar stuff and both look like this (Names may differ, as well as values):
Column A, C, D and F contain times (in m:ss).
Column B and E both calculate the time-difference between NameX and NameY and add ">, < or ~ ~" depending on the actual difference (ignore the coloring).
Now here comes my problem: I want to find 3 minima (on Sheet 3).
Minimum 1 is easy, as I can just use this function (it automatically filters out column B and E):
MIN('Sheet 1'!A2:F2, 'Sheet 2'!A2:F2)
Minimum 2 and 3 are were I struggle.
Minimum 2: Using the example values, I want to find the minimum of (1:01+1:02), (1:02+1:05), (1:01+1:01) and (1:01+1:02) (+ whatever times are on sheet 2). Result should be 2:02.
Minimum 3: Again, using the example values, I want to find the minimum of (1:01+1:02+1:03), (1:02+1:05+0:30), (1:01+1:01+1:12) and (1:01+1:02+2:02) (+ whatever times are on sheet 2). Result should be 2:37.
I am currently using this formula (for minimum 3):
=MIN(
IFERROR(FILTER(IFERROR(ARRAYFORMULA({'Sheet 1'!A2:F2}+{'Sheet 1'!A3:F3}+{'Sheet 1'!A4:F4})),
IFERROR(ARRAYFORMULA({'Sheet 1'!A2:F2}+{'Sheet 1'!A3:F3}+{'Sheet 1'!A4:F4}))<>0)),
IFERROR(FILTER(IFERROR(ARRAYFORMULA({'Sheet 2'!A2:F2}+{'Sheet 2'!A3:F3}+{'Sheet 2'!A4:F4})),
IFERROR(ARRAYFORMULA({'Sheet 2'!A2:F2}+{'Sheet 2'!A3:F3}+{'Sheet 2'!A4:F4}))<>0))
)
Some notes: The inner IFERROR-function is needed to filter out errors that obviously occur when trying to add up column B and E. FILTER-function filters out columns that are empty (there's none in this example). The second IFERROR-function filters out FILTER-functions that return an error when they get no input at all (all columns in a sheet are empty). I want to filter of these since I don't want to get 0:00 as result
My problem is this: In my actual sheet I have 11 sheets with 16 rows to add up, but I don't want to use the formula above and create an insane monster of a formula that would x-times as long as the formula above.
So my question is: Is there an easier way to solve this problem for mimimum 3 (and therefore 4, 5, 6 ...) that I'm not seeing?
It's a little monstrous, but this might work:
=MIN(FILTER({
MMULT(SEQUENCE(1,ROWS(Sheet1!A2:F),1,0),N(Sheet1!A2:F));
MMULT(SEQUENCE(1,ROWS(Sheet2!A2:F),1,0),N(Sheet2!A2:F));
MMULT(SEQUENCE(1,ROWS(Sheet3!A2:F),1,0),N(Sheet3!A2:F));
MMULT(SEQUENCE(1,ROWS(Sheet4!A2:F),1,0),N(Sheet4!A2:F));
MMULT(SEQUENCE(1,ROWS(Sheet5!A2:F),1,0),N(Sheet5!A2:F));
MMULT(SEQUENCE(1,ROWS(Sheet6!A2:F),1,0),N(Sheet6!A2:F));
MMULT(SEQUENCE(1,ROWS(Sheet7!A2:F),1,0),N(Sheet7!A2:F));
MMULT(SEQUENCE(1,ROWS(Sheet8!A2:F),1,0),N(Sheet8!A2:F));
MMULT(SEQUENCE(1,ROWS(Sheet9!A2:F),1,0),N(Sheet9!A2:F));
MMULT(SEQUENCE(1,ROWS(Sheet10!A2:F),1,0),N(Sheet10!A2:F));
MMULT(SEQUENCE(1,ROWS(Sheet11!A2:F),1,0),N(Sheet11!A2:F))},
{1,0,1,1,0,1}))

Setting a Cap in Google Sheets

I'm trying to set a cap of 10 on a particular cell, "Available". We can only hold 10 of this product at a time, and receive 1 at the beginning of each month. The "Available" cell currently has 2 inputs. The first input, "Accumulated", increases by 1 at the beginning of every month. The other, "Used", is incremented manually when the product is used. "Available" = "Accumulated" - "Used". Here is an exampleExample of Sheets
The problem I am having is in the last row, where it has 19 accumulated and 0 used. If I were to set up a formula in the "Available" cell to cap at 10 with something like,
MIN(10,"Accumulated"-"Used")
it would stay at 10 even if the "Used" number increases, but I need it to go down to 9, because we will not have another product in stock until the beginning of the next month.
I feel like if I could make another column that shows how many time we would have received a new product, but we could not store it, that would fix the problem. How would I create that column, and just increment it each month that the available is already at 10?
If I understand your question correctly, you would need the following formula
=IF(N5-O5<9,N5-O5,MIN(9,N5-O5))

Count selected elements for each line and create an arrayformula that groups by number of counts

We have asked users:
What to do with the money?
[ ] paint the bridge
[ ] rebuild the school
[ ] keep the money
[ ] Other : [____________________]
Here is the spreadsheet with their answers:
A B
1 Name Choices
2 Lilia paint the bridge, rebuild the school, keep the money
3 Paul rebuild the school, paint the bridge, do something else
4 Margerite keep the money, I don't know, do what you want
5 John paint the bridge
...
800
I want a formula that output the number of official choices (excluding other) picked per user.
With the first 4 rows of data, the formula would output this table:
D E
Nbr of choices a user made Frequency (Nbr of users who made these choices)
0 0
1 2
2 1
3 1
Couldn't find a way to get this right from a single formula. For a starter, I wanted to split each line (of B2: B) by "," but couldn't find a way to apply a fn (split) to each line in an formula...
Even with 800 rows of data (B2:B), the resulting table (D2:E5) would always be 4 rows long plus titles (and two column wide)
I could do this in C2, and replicate manually with the "+" corner icon...
=countif(B2;"*rebuild the school*")+countif(B2;"*keep the money*")+countif(B2;"*paint the bridge*")
And then do in E2:
=arrayformula(countif(C2:C;D2:D5))
But I'd like to generate the table of frequencies in one formula, without any manual action (without C column).
So I am looking for a way to "map" the first function to each row, put this in the second fn.
ANSWER by Akshin Jalilov EXPLAINED
This is the answer by Akshin Jalilov, but shorter (and with international notations)
=ARRAYFORMULA(COUNTIF(ARRAYFORMULA(IF(B2:B="";;COUNTIF(ARRAYFORMULA
(IFERROR(IF(FIND("paint the bridge";B2:B);Row(B2:B);0)));"="&row(B2:B))
+COUNTIF(ARRAYFORMULA(IFERROR(IF(FIND(
"rebuild the school";B2:B);Row(B2:B);0)));"="&row(B2:B))
+COUNTIF(ARRAYFORMULA(IFERROR(IF(FIND(
"keep the money";B2:B);Row(B2:B);0)));"="&row(B2:B))));"="&D2:D5))
Step1:
IF(FIND("rebuild the school";B2:B);Row(B2:B);0)
This means, for each row (B2:B) find "rebuild the school". If you find it, return the number of the row, otherwise, return 0.
Step2:
=ARRAYFORMULA(IFERROR(Step1))
Wrap this in an ARRAYFORMULA so that you return the results for each row.
I think IFERROR is there to prevent an error from stopping the process.
Step3:
=ARRAYFORMULA(IF(B2:B="";;COUNTIF(ARRAYFORMULA(IFERROR(IF(FIND("paint the bridge";B2:B);Row(B2:B);0)));"="&row(B2:B))+countif(Step2)+countif(ARRAYFORMULA(IFERROR(IF(FIND("keep the money";B2:B);Row(B2:B);0)));"="&row(B2:B))))
This will count valid votes made by each users. This is equivalent to C2 formula referred in my manual process. But is it now part of a single global formula.
Step4:
Lastly, the rest of the formula counts frequencies of each voting count possibilities.
I know this formula is large but this is the closest I got to what you want.
Now to make it easy, name your responses range "Responses". I assume it is B2:B.
Here is the formula:
=ARRAYFORMULA(Countif(ARRAYFORMULA(IF(Responses="",,COUNTIF(VLOOKUP(row(Responses),({ARRAYFORMULA(Row(Responses)),ARRAYFORMULA(IFERROR(IF(FIND("paint the bridge",Responses),Row(Responses),0))),ARRAYFORMULA(IFERROR(IF(FIND("rebuild the school",Responses),Row(Responses),0))),ARRAYFORMULA(IFERROR(IF(FIND("keep the money",Responses),Row(Responses),0)))}),2),"="&row(Responses))+COUNTIF(VLOOKUP(row(Responses),({ARRAYFORMULA(Row(Responses)),ARRAYFORMULA(IFERROR(IF(FIND("paint the bridge",Responses),Row(Responses),0))),ARRAYFORMULA(IFERROR(IF(FIND("rebuild the school",Responses),Row(Responses),0))),ARRAYFORMULA(IFERROR(IF(FIND("keep the money",Responses),Row(Responses),0)))}),3),"="&row(Responses))+COUNTIF(VLOOKUP(row(Responses),({ARRAYFORMULA(Row(Responses)),ARRAYFORMULA(IFERROR(IF(FIND("paint the bridge",Responses),Row(Responses),0))),ARRAYFORMULA(IFERROR(IF(FIND("rebuild the school",Responses),Row(Responses),0))),ARRAYFORMULA(IFERROR(IF(FIND("keep the money",Responses),Row(Responses),0)))}),4),"="&row(Responses)))),"="&D2:D5))
Here is an example if how it works. I am not sure which one exactly you wanted so added both

Resources