So i'm trying to count who sold something at the end of the day doesn't matter how many item that person sold.
Name Shoes Shirts Hat
A 1 2
B 1
C 1 3
D 1 1
E
So if A sold then should count as 1 person sold something
If E is not selling anything that not count as anything
Example spreadsheet with data from C6 through F10:
| C | D | E | F |
5 |name|shoe|shirt|hat|
6 | a | 1 | 1 | 0 |
7 | b | 0 | 1 | 0 |
8 | c | 1 | 1 | 0 |
9 | d | 1 | 1 | 0 |
10| e | 0 | 0 | 0 |
You could use this formula on the data example above:
=SUM(IF($D$6:$D$10+$E$6:$E$10+$F$6:$F$10>0,1,0))
but you have to hit Ctrl+Shift+Enter, not just Enter (because it is an array formula). You will know you did this correctly because it automatically adds { } around the formula, so it will look like this:
{=SUM(IF($D$6:$D$10+$E$6:$E$10+$F$6:$F$10>0,1,0))}
What this formula does:
IF(D6+E6+F6 > 0, 1,0) for each row until 10+E10+F10, which leaves you with either a 1 or 0 for each row; 1 if the sum of the row > 0 and 0 if it was not > 0. It then adds up the info and gives you a count of any rows that had at least 1 sale of either a shoe, shirt or hat.
Related
I'm doing a case-control study about ovarian cancer. I want to do stratified analyses for the different histotypes but haven't found a good way of doing it in SPSS. I was thinking about copying the information about the diagnoses from the cases to the controls, but I don't know the proper syntax to do it.
So - what I want to do is to find the diagnosis within the case-control pair, copy it, and paste it into the same variable for all the controls within that pair. Does anyone know a good way to do this?
ID = unique ID for the individual, casecontrol = 1 for case, 0 for control, caseset = stratum, ID for each matched group of individuals.
My dataset looks like this:
ID | casecontrol | caseset | diagnosis
1 | 1 | 1 | 1
2 | 0 | 1 | 0
3 | 0 | 1 | 0
4 | 0 | 1 | 0
5 | 1 | 2 | 3
6 | 0 | 2 | 0
7 | 0 | 2 | 0
8 | 0 | 2 | 0
And I want it to look like this:
ID | casecontrol | caseset | diagnosis
1 | 1 | 1 | 1
2 | 0 | 1 | 1
3 | 0 | 1 | 1
4 | 0 | 1 | 1
5 | 1 | 2 | 3
6 | 0 | 2 | 3
7 | 0 | 2 | 3
8 | 0 | 2 | 3
Thank you very much.
According to your example, in each value of caseset you have one line with diagnosis equals some positive number, and in the rest of the lines diagnosis equals zero (or is missing?).
If this is true, all you need to do is this:
aggregate out=* mode=add overwrite=yes /break=caseset /diagnosis=max(diagnosis).
The above command will overwrite the original data, so make sure you have that data backed up, or use a different name for the aggregated data (eg /FullDiagnosis=max(diagnosis) .
I am encountering something I am finding challanging to understand how to script and I was hoping maybe someone who has better excel knowledge may be able to help!
UserID is in column A, and DateofTransaction Is in column I,
I have a code that identifies any change between user id or Month as a 1 else 0. :
ENTERED INTO COLUMN O
=IF(A2<>A1,1,IF(I2<>I1,1,0))
if the ids are Not the same then 1, if the ids are the same then it checks if the months are not the same then 1 too, if both are satisfied then a 0.
Then to try to create some logic where it can group each set I have written
Column O is the
=IF(O2+O3=2,1,IF(O2=0,IF(O3=1,2,IF(O2+O3=0,Q1+1,null))))
Which just identifies the groups of months but unsuccessfully at the moment, What I am looking for is Blank cells if it is not the only one in the month for the user. example excel below
Column A | Column I | Column O | Column Q | Column R |
----------------------------------------------------------------------------------------------
user id | date | 0 or 1 match | transactions per month| Transacting month count
-----------------------------------------------------------------------------------------------
1 | Mar-16 | 1 | 1 | 6
1 | Apr-16 | 1 | BLANK | 6
1 | Apr-16 | 0 | 2 | 6
1 | Aug-16 | 1 | 1 | 6
2 | Aug-16 | 1 | BLANK | 1
2 | Aug-16 | 0 | BLANK | 1
2 | Aug-16 | 0 | BLANK | 1
2 | Aug-16 | 0 | 4 | 1
I will then need to do an Average transactions per month for each user over their lifetime individually. The transacting month count was created with a LookUp to calculate their relative month count.
Any suggestions would be greatly appreciated!
Thanks,
C
Here is the formula that you can use for your question regarding formula in column Q:
=IF(O2+O3=2,1,IF(OR(AND(O2+O3=0,O3<>""),(AND(O2+O3=1,O2=1))),"",COUNTIFS(I:I,I2,A:A,A2)))
Put this in Cell Q2 and drag it down till you have data.
I would like to return the count of the number of rows for which ANY of the columns have the number 1. The table is three columns, and each column can contain either 0, 1, 2, or 3. Example:
Col1 | Col 2 | Col 3
0 | 1 | 0
1 | 2 | 3
0 | 0 | 0
3 | 1 | 1
2 | 2 | 2
etc.
I would like the formula to return 3.
Here you go:
=SUMPRODUCT(--((A1:A10=1)+(B1:B10=1)+(C1:C10=1)>0))
Change the 10s to however far down you need to go.
I have a sheet something like this
A B C D
1 2 2
2 3 3
4 5 5
5 7 9
10
11
12
I would like column D to show values of col A if col B values exist in col C
Example:
A B C D
1 2 2 1
5 7 9 -
D would have a value of 1 since Col b val is in Col C and in row 4 Col D would have no value at all
Yes A,B,C,D are labels as per the comments
You don't need VLOOKUP here. I think MATCH is a better choice.
Try this:
D1:D4 =IF(ISERROR(MATCH(B1,$C$1:$C$7,0)),"",A1)
(This assumes that your numerical values start in row 1.)
The output looks like this:
+---+---+---+----+---+
| | A | B | C | D |
+---+---+---+----+---+
| 1 | 1 | 2 | 2 | 1 |
| 2 | 2 | 3 | 3 | 2 |
| 3 | 4 | 5 | 5 | 4 |
| 4 | 5 | 7 | 9 | |
| 5 | | | 10 | |
| 6 | | | 11 | |
| 7 | | | 12 | |
+---+---+---+----+---+
You can do this with a combination of vlookup, offset and iserror like so:
=IFERROR(IF(VLOOKUP(B2,C:C,1,0)=B2,OFFSET(B2,0,-1)),"-")
offset used with the -1 parameter will return the cell one column to the left, so you do not need to rearrange the columns in your actual worksheet. iserror will check if the lookup failed, and return the specified default value. Finally, you can also specify the exact range to be looked up, in this case as
VLOOKUP(B2,$C$2:$C$8,1,0)
Sheet 1
A | B | C
0 | 100001 | 855.71
0 | 100002 | 73.68
0 | 100003 | 704.58
0 | 100004 | 0
0 | 100005 | 0
0 | 100006 | 604.57
0 | 100007 | 15638.66
0 | 100008 | 1085.85
Sheet 2
A | B | C
0 | 100001 |
0 | 100002 |
0 | 100003 |
0 | 100004 |
0 | 100005 |
0 | 100006 |
0 | 100007 |
0 | 100008 |
0 | 100009 |
0 | 100010 |
0 | 100011 |
This is what my 2 sheets in Excel looks like, I need to do a vlookup on the 2nd page that looks up the table in the first sheet, and prints out what is in Column C if column A and B match. So the match 0 and 100001 would display 855.71.
I've tried concatenating colum A and B together and matching that using this formula:
=VLOOKUP(A3&B3,Sheet1!$A$1:$D$8,3,FALSE)
But i just get the #N/A error, any help would be great.
You'll have to concatenate in a new 4th column on Sheet1 to use Vlookup in this manner. Instead though, you could use sumifs() since your lookup is a number and the lookup values appear to be unique:
=sumifs(Sheet1!C:C,Sheet1!A:A,A1,Sheet1!B:B,B1)
As an alternative, if the values in C are not numerical and you don't want them summed, you could use a combination of index() and sumproduct() where sumproduct() will provide the row number on which a match is found and index() will retrieve the value from that row:
=index(Sheet1!C1:C500, sumproduct((A1=Sheet1!A1:A500)*(B1=Sheet1!B1:B500)*Row()), 1)
That's ugly but it will get you out of having to make a superfluous column just for concatenating a key. Note that this will only work if there A and B are unique. If there are more than row where A and B are the same, then the ROW() returned will be summed and the lookup will be incorrect.