How to merge two Spreadsheets into one in google spreadsheets - google-sheets-api

There are two Spreadsheets namely main and secondary. Main has 3 sheets in it and Secondary has 1 sheet under it. For simplicity I'll show modified version of them both under
Main spreadsheet
Name Qrating Brating Crating
A 8 5 4
B 5 2 1
C 6 7 9
Secondary spreadsheet includes personal details of same people present in Main spreadsheet as seen below.
Name Age Rank qualified
A 23 2 yes
B 45 22 yes
C 44 23 yes
I have looked up ways to merge and combine but all seem to be ways in combining data vertically, but what i want is all the data in secondary to be added in Main file in accordance to the name. I don't seem to find the solution online where data is filled horizontally after tallying a common column between two files. if anyone can give solution or guide me to a direction that would be very helpful. Thankyou.
end result should be like this when merged
Name Qrating Brating Crating
A 8 5 4
B 5 2 1
C 6 7 9
Name Age Rank qualified
A 23 2 yes
B 45 22 yes
C 44 23 yes
Name Age Rank qualified Qrating Brating Crating
A 23 2 yes 8 5 4
B 45 22 yes 5 2 1
C 44 23 yes 6 7 9

It is very easy to do this with click on feature in Microsoft Excel, I was expecting the same in Google sheet but it seems the add-ons help for this as I didn't find any tool in sheets itself. There are many add-ons to achieve this, I am using Merge Sheets add on for this.

You can merge multiple sheets form different spreadsheets like this
=query({
IMPORTRANGE("ID_1"; "SheetX!A2:E");
IMPORTRANGE("ID_2"; "SheetX!A2:E");
IMPORTRANGE("ID_3"; "SheetX!A2:E")
};"SELECT * WHERE Col1 IS NOT NULL")
and then adapt query as you need. Wait for an example from your side. Sincerely yours.

Related

Choosing companies from a dataframe with monthl returns based on company list of other dataframe

I'm currently writing my master thesis and I would like to calculate the portfolio returns for a list of companies. Therefore, I want to choose the companies from the dataframe with their monthly returns. I want to select the companies, which are in another dataframe.
The dataframe with the returns looks like that:
The second dataframe with the company names according to which I want to choose, looks like that:
I tried something like this:
mrt.loc[mrt['Company Name'] == SL1['Company Name']], which just gives me the Error 'Company Name'. I checked and the spelling should be correct.
I tried as well this:
mrt.loc[mrt == SL0['Company Name']]
This gives me a list of companies but I need as well the monthlyreturns from the dataframe mrt.
So as a recap I want the rows from mrt according to the company names in the dataframe SL0. And I need to do this afterwards with other dataframes like SL0 but with different length.
Could someone help? Thank you very much and have a nice day.
isin() would resolve this issue.
df
###
Company Name value1
0 Apple 1
1 Google 2
2 Microsoft 3
3 Facebook 4
4 Tesla 5
5 Amazon 6
6 Alphabet 7
7 Oracle 8
8 IBM 9
9 Facebook 10
df2
###
value2 value3 Company Name
0 51 11 Apple
1 52 22 Google
2 35 33 Microsoft
3 54 44 Facebook
Selecting
df[df['Company Name'].isin(df2['Company Name'])]
###
Company Name value1
0 Apple 1
1 Google 2
2 Microsoft 3
3 Facebook 4
9 Facebook 10

Count instances of number in Row

I have a sheet formated somewhat like this
Thing 5 6 7 Person 1 Person 2 Person 3
Thing 1 1 2 7 7 6
Thing 2 5 5
Thing 3 7 6 6
Thing 4 6 6 5
I am trying to find a query formula that I can place in the columns labeled 5,6,7 that will count the number of people who have that amount of Thing 1. For example, I filled out the Thing 1 row, showing that 1 person has 6 of Thing 1 and 2 people have 7 of Thing 1.
You can use this function: "COUNTIF".
The formula to write in the cells will look like this:
=COUNTIF(E2:G2;"=5")
For more information regarding this function, check the documentation: https://support.google.com/docs/answer/3093480?hl=en

Access 2010: data rows as column headings?

I'm using MS Access 2013.
I need to display AND EDIT a grid of data based on three tables:
UnitID UnitName
1 Unit1
2 Unit2
3 Unit3
ProdID ProdName
1 Furniture
2 Food
3 Other
UnitID ProdID Forecast
1 1 10
1 2 20
1 3 30
2 1 40
2 2 50
2 3 60
3 1 70
3 2 80
3 3 90
so it looks like:
Unit1 Unit2 Unit3
Furniture 10 40 70
Food 20 50 80
Other 30 60 90
Furthermore, the query must be editable (user should be able to enter his forecast data).
Any idea how to do this in Access 2010? I've looked into pivots and crosstab queries, but they use aggregate functions and thus aren't editable... but in my case, the source of the data is unambiguous so an editable option should exist? Anyone has an idea how to get the data in editable format?
Thanks!
Jur.
Create a temp table and fill it with the data from your crosstab query. Use that table as the source for a form, which will be editable. In the beforeupdate event of the form, add code to update the original source table.
Thanks all,
distributing any kind of exe is not an option due to security measurements in the client's environment (they can run Office and little else). So I'm going for the temp table option anyway... any pointers for a template solution to modify to my needs?
Thanks again!
Jur.

How to fit multiple equal references into table structure?

How to fit multiple equal references into table structure? How could I do that? For example: I have list of classmates:
1 Peter
2 Jack
3 John
4 Mary
5 Birgit
6 Stella
7 Janus
8 Margo
9 Fred
Now I want to define fellowships. In first place, let's limit that every kid may belong to one fellowship. So we could have 3 fellowships:
[Peter, Jack]
[John, Mary, Birgit]
[Stella, Janus, Margo, Fred]
All members are equal, so they all should reference to other members. Is there better ways to define such relations than just to have table of pairs? Like:
1 2
3 4
3 5
4 5
4 3
5 3
5 4
6 7
6 8
6 9
7 6
7 8
7 9
8 6
8 7
8 9
9 6
9 7
9 8
If using table of pairs, is it better to describe relation both way (like above), or is it enough to have link just from one way to another? What are the benefits of both ways?
Table of pairs does not constrain any member into just one fellowsip, but how would it possible?
I was looking for SQL table solution, but maybe there are better tools for handling such data-structures, so I added nosql-tag too. I am looking for right tools for such data, but I am eager to know, how to fit it in SQL tables too.
Yes, there is another way. If you have "fellowships", then you do not have pair-wise relationships. STart with a Fellowships table that has a FellowshipsId.
Then you would have a FellowshipsKids table. This is called a junction table, and it would have one row for each member of each fellowship. It would have rows like this:
FellowshipId KidId
1 1
1 2
2 3
2 4
2 5
. . .
What you have is an m-n relationship between fellowships and kids -- one fellowship can have multiple kids, one kids can be in multiple fellowships. A junction table is the standard way of represent this in a relational database.

Linking worksheets based on a pivot column

I have a spreadsheet linking issue. For example let the data in the work books look like this
Book1
A 1 aaa
B 2 bbb
C 3 ccc
Now I link this sheet to another sheet by reference and it has same values as in here
Book 2
A 1 aaa
B 2 bbb
C 3 ccc
Now if I add another column in Book 2 like below
Book 2
A 1 aaa 10
B 2 bbb 20
C 3 ccc 30
Now if I link this new column back to Book1 it looks like below
Book 1
A 1 aaa 10
B 2 bbb 20
C 3 ccc 30
But now if I sort column 1 in book 1 it doesn't sort the column4 because that is referenced to Book 2 which looks like below
Book 1
C 3 ccc 10
B 2 bbb 20
A 1 aaa 30
But expected output is
Book 1
C 3 ccc 30
B 2 bbb 20
A 1 aaa 10
But I want the sorting to happen on the new column that is added as well. A solution I could think of is to share a single sheet. But that doesn't serve my purpose so I need a linking which is sophisticated enough to sync across the books. Is there a pivot column based linking where the column1 in two books are taken as a reference when the manipulation happens on any sheet. Any help is appreciated.
I'm not sure why this isn't working for you, but I may be misinterpreting how you've set this up.
I've set up two workbooks, each with identical data for the first three columns, the fourth column in Book1 being linked to the same column in Book2.
Here, you can see the formula view after I sorted on Column A.
This will not work properly if you had previously enabled Auto Filter Before putting in the links, since the Auto Filter will not have extended the filter range by itself. To fix this particular issue, simply disable and re enable the Auto Filter (You should see the drop-down icon on Column D after that).
I've run into this type of "missorting" problem before. My solution was always to copy and paste the formulas in a different sheet as values.
Otherwise you could make column D dynamic through VLOOKUP and not reference hard cell numbers.