I have two sheets sheet 1 and sheet 2, what I have to do is copy the values in sheet 1 to sheet 2
sheet 1 : I have two type of users with corresponding weights
user 1 user 2 7
user 1 user 3 19
user 1 user 7 5
user 3 user 2 1
user 2 user 7 1
sheet 2
user 1 user 2 user 3 user 7
user 1
user 3
user 2
user 7
The final result should be something like this: user 1 - > user two has weight 7 so this value appears in that cell and so on
user 1 user 2 user 3 user 7
user 1 0 7 19 5
user 3 0 1 0 0
user 2 0 0 0 1
user 7 0 0 0 0
Is there a way to do this? I know I can pass values between two excel sheets but I'm confused how to do this in this case
UPDATED: CIRCULAR REFERENCE ERROR
sheet 2
Assuming both the sample you have given starts from the top left of the sheet, enter the following formula in B2 (for user 1, user 1) and drag across the table:
=SUMIFS(Sheet1!$C:$C,Sheet1!$A:$A,$A2,Sheet1!$B:$B,B$1)
The output will be:
user 1 user 2 user 3 user 7
user 1 0 7 19 5
user 2 0 0 0 1
user 3 0 1 0 0
user 7 0 0 0 0
It uses the users in the row and column as the criteria to match the same in column 1 and 2 of sheet 1, and adds the weight. This will work regardless of whether there is duplication or not.
Related
I have a df which contains customer data without a primary key. The same customer might show up multiple times.
I have a field (df2['campaign']) that is an int and reflects how many times the customer shows up in the df. There are also many customer attributes.
In my example, going from top to bottom, for each row (i.e. customer), I would like to find all n rows (i.e. all n customers) whose values of the education and default columns are the same. Remember n is the int contained in df2['campaign']
So as shown below, for row 0 and 1 I should search 1 row but find nothing because there are no matching values for education-default combinations.
For row 2 I should search 1 row (because campaign == 1) where education-default values match, and find 1 row in index 4.
df2.head()
job marital education default campaign housing loan contact
0 3 1 0 0 1 0 0 1
1 7 1 3 1 1 0 0 1
2 7 1 3 0 1 2 0 1
3 0 1 1 0 1 0 0 1
4 7 1 3 0 1 0 2 1
Use df2_sorted = df2.sort(['education', 'default'], ascending=[1, 1]).
Then if your data is not noisy, the rows should become neighbors.
Id
1
2
3
4
2
3
3
3
Questions
create one new column and that is newid
output should be like this.
id newid
1 1
2 1
3 1
4 1
2 0
3 0
3 0
3 0
Please suggest me how can I do it and which formula to be used in excel
At Column A i have this values 1
0
3
2
0
5
1
1
1
0
2
1
1
1
0
2
1
1
1
0
0
3
0
2
0
0
3
1
This list grows everyday.
I need a formula to put on every cell of column B that counts upwards how many values bigger than 1 are until the next value = 1 is found.
In another words i need to count how many values larger than 1 are between 1's.
The pretended result would be something like this:
1
0
3
2
0
5
1 3
1
0
2
1 1
1
0
2
1 1
1
0
0
3
0
2
0
0
3
1 3
Thanks in Advance
I would use a helper column, if this is acceptable.
So to create a running count of numbers greater than one which resets each time it encounters a '1', enter this starting in B2 and pull down (I'm assuming the data has a heading and the list starts with a 1) :-
=IF(A2=1,0,B1+(A2>1))
Then to display the counts at each '1' value (but not for repeated ones) enter this in C2 and pull down:-
=IF(AND(A2=1,A1<>1,ISNUMBER(A1)),B1,"")
It's also possible to do it with an array formula, but not sure if it's worth the effort:-
=IF(AND(A2=1,A1<>1),
COUNTIF(
OFFSET(
A$1,
MAX(ROW(A1:A$2)*(A1:A$2=1))-ROW(A$1)+1,,
MAX(ROW(A1))-MAX(ROW(A1:A$2)*(A1:A$2=1))),
">"&0),
"")
to be entered in B2 with Ctrl Shift Enter and pulled down.
I am trying to work out the ranking of top 3 users at different organisations and have the data presented horizontally for each user so it can be inputted into our email system to personalise emails.
I am able to create a ranking vertically but I am not sure how to get the formula to rank based on organisation and return value across.
Here is what I need to have in the end:
Name Organisation Usage First Second Third
User 1 Organisation 1 8 User 3 User 5 User 2
User 2 Organisation 1 10 User 3 User 5 User 2
User 3 Organisation 1 222 User 3 User 5 User 2
User 4 Organisation 1 1 User 3 User 5 User 2
User 5 Organisation 1 14 User 3 User 5 User 2
User 1 Organisation 2 215 User 4 User 1 User 5
User 2 Organisation 2 18 User 4 User 1 User 5
User 3 Organisation 2 12 User 4 User 1 User 5
User 4 Organisation 2 310 User 4 User 1 User 5
User 5 Organisation 2 161 User 4 User 1 User 5
I can return a ranking vertically one organisation at a time using
=INDEX($A$2:$A$6,MATCH(1,INDEX(($C$2:$C$6=LARGE($C$2:$C$6,ROWS(H$1:H1)))*(COUNTIF(H$1:H1,$A$2:$A$6)=0),),0))
If someone could help me run this formula based on each organisation and horizontally that would be fantastic!
Thanks,
Sarah.
Non-Empty Usage Solution:
Assuming your data starts in A1 Like so:
A B C D E F
---------------------------------------------------------
1 | Name Organisation Usage First Second Third
2 | User 1 Organisation 1 8 User 3 User 5 User 2
3 | User 2 Organisation 1 10 User 3 User 5 User 2
4 | User 3 Organisation 1 222 User 3 User 5 User 2
5 | User 4 Organisation 1 1 User 3 User 5 User 2
6 | User 5 Organisation 1 14 User 3 User 5 User 2
7 | User 1 Organisation 2 215 User 4 User 1 User 5
8 | User 2 Organisation 2 18 User 4 User 1 User 5
9 | User 3 Organisation 2 12 User 4 User 1 User 5
10| User 4 Organisation 2 310 User 4 User 1 User 5
11| User 5 Organisation 2 161 User 4 User 1 User 5
You can change your formula starting in D2 to:
=INDEX($A$2:$A$11,MATCH(1,INDEX(($C$2:$C$11=LARGE(($B$2:$B$11=$B2)*$C$2:$C$11,COLUMNS($C2:C2)))*(COUNTIF($C2:C2,$A$2:$A$11)=0),),0))
What I changed:
Added ($B$2:$B$11=$B2) inside the LARGE which multiplies all the Usage values for other organizations by 0. Which then won't be picked up by the LARGE function.
Changed the ROWS(H$1:H1) to COLUMNS($C2:C2) so you can rank horizontally
I also changed the cell references to the entire dataset rows 2 to 11
Solution with possible empty Usage:
If the Usage is empty (for all users in the same organization) and you desire the First, Second, and Third column to be blank then also, like so:
A B C D E F
---------------------------------------------------------
1 | Name Organisation Usage First Second Third
2 | User 1 Organisation 1 8 User 3 User 5 User 2
3 | User 2 Organisation 1 10 User 3 User 5 User 2
4 | User 3 Organisation 1 222 User 3 User 5 User 2
5 | User 4 Organisation 1 1 User 3 User 5 User 2
6 | User 5 Organisation 1 14 User 3 User 5 User 2
7 | User 1 Organisation 2
8 | User 2 Organisation 2
9 | User 3 Organisation 2
10| User 4 Organisation 2
11| User 5 Organisation 2
We can accomplish this by checking if the entire Usage for the Organization is 0. Then we can blank out all the ranks for that Organization.
To check if the sum of the usages for the organization is 0 we can use SUMPRODUCT: So for cell D2 that would look like:
=SUMPRODUCT(($C$2:$C$11)*($B$2:$B$11=$B2))=0
Then we can just wrap an IF around everything and blank it if the above statement returns true. So our final formula would look like:
=IF(SUMPRODUCT(($C$2:$C$11)*($B$2:$B$11=$B2))=0,"",INDEX($A$2:$A$11,MATCH(1,INDEX(($C$2:$C$11=LARGE(($B$2:$B$11=$B2)*$C$2:$C$11,COLUMNS($C2:C2)))*(COUNTIF($C2:C2,$A$2:$A$11)=0),),0)))
^^ Throw whatever you want in there
Now if you want the text to say anything else, just put that text inside the quotes for the TRUE condition of the IF statement.
I have a data set that is spread across five columns. Sample of data:
Raw Data End Results
A B C D E A B C D E
1 2 2 1 6 1 2 2 1 6
0 3 3 0 6 0 3 3 0 6
1 2 2 1 6
0 3 3 0 6
1 2 2 1 6
0 3 3 0 6
1 2 2 1 6
0 3 3 0 6
1 2 2 1 6
0 3 3 0 6
1 2 2 1 6
0 3 3 0 6
1 2 2 1 6
0 3 3 0 6
The length of record varies from 10 to 40.
The data is to help me keep record of inventory and I wish to know which orders are popular.
Unfortunately I am still using Excel 2003.
Because I am not really sure what you have, this is deliberately simple:
In ColumnG Row1 put:
=A1&B1&C1&D1&E1
and copy down to suit. Select ColumnG and Paste Special, Values. Select ColumnG and sort. Insert in H1 and copy down to suit:
=COUNTIF(G$1:G1,G1)
1 should indicate the first ("unique") instance of each of the rows of Raw Data (and the other numbers the number of repetitions - up to 7 in your example, so one 'original' and six 'copies'.