Google Sheets Indexing and Matching issue - google-sheets

CleanedData tab RawData tab I am tracking clients in google sheets with 2 different tabs, RawData and CleanedData.
Both tabs have 11 different columns, one being a "purchase date" column
The RawData tab keeps track of all clients that have signed up for info sessions regardless if they made a purchase or not, so every time a client has made a purchase it populates another row with the date of purchase.
In the cleaneddata tab I want to clean all the data from the RawData tab into one row for each client, for example if client "X" has 5 rows of data in the RawData tab but only one of those rows has his purchase date, I then want to pull that row with the purchase date into the cleaneddata tab.
The issue I'm having is that the purchase date is not copying over to the cleaneddata tab and I believe it is because it's accounting for the duplicate data rows that are in the RawData tab, that I need to be there.
The equation I'm using in the purchase date cell of the cleaneddata tab is:
=index(RawData!$A$1:$L, match(1,($A428=RawData!$A$1:$A)*($L428=RawData!$L$1:$L),0),match(J$1,RawData!$A$1:$L$1,0))
Is there anyway to rework this equation to account for the duplicates in the RawData tab so that the purchase data will copy over?
Any help is greatly appreciated,
Thank you
Edit: I can not share the sheet file for security purposes but I uploaded a picture of what the RawData and CleanedData tabs look like, I need some equation or method to pull the purchase date from the RawData tab to the cleaneddata tab that also accounts for the repeated rows in the RawData tab

If you just need to get a subset of rows that match a specific criteria (such as given column in the row containing a value) you can use the =FILTER or =QUERY functions.
eg.
=FILTER(RawData!A:L, RawData!J:J <> "")
or
=QUERY(RawData!A:L, "SELECT * WHERE J IS NOT NULL")
Translated into plain English, both of these effectively say, "Get every row in the range RawData!A:L where column RawData!J:J isn't empty.
FILTER is fast and powerful.
QUERY gives you even more control but is more complex to use. You can run some operations on specific columns or change the data format. eg. If you'd like to change the format of the dates in column J from US-format to ISO-format, you could use:
=QUERY(RawData!A:L, "SELECT * WHERE J IS NOT NULL FORMAT J 'YYYY-MM-DD'")
See https://developers.google.com/chart/interactive/docs/querylanguage for the QUERY docs.

Related

Trying to auto-generate SKUs in Google Sheets using prefix and sequence number but it breaks when sheet is sorted

I want to automatically generate unique, incremented ids (SKUs) for products in my inventory using Google Sheets. These SKUs should be immutable and not change when the sheet is sorted. This screenshot shows my flawed attempt to do this:
The formula I have for column A is:
=if($B2<>"",$B2 & TEXT(COUNTIF($B$2:$B2,$B2),"-0000"),"")
That formula appears to give the desired result. However, if I sort by the values in Column C, SKUs become associated with different Item Names, which is a problem. How can I modify the spreadsheet to get immutable, auto-generated SKUs?
Update:
I would like to be able to add additional rows/SKUs to the sheet over
time
Here is a link to the sample spreadsheet
I've added a sheet ("InventoryMaster(Unsorted") to your spreadsheet.
This sheet would be used to add your prefixes and items only. Once added, you would never sort, insert rows, delete rows or items, etc. Just keep adding the next prefix and item into the next open row, in Col B and Col C. Col A has a formula that will create the static SKUs from that unchanging and ordered information. (I've hidden that formula-containing Col A, so that you only have to enter the manual data and don't have to worry about accidentally overwriting the formula or its results. It's still there at all times, serving its purpose in the background.)
Then, other sheets (see my added "Erik Help" sheet) can reference that "immutable" list, giving you the ability to sort without losing SKU connection.
Here is the A1 formula from the 'InventoryMaster(Unsorted)' sheet:
=ArrayFormula({"SKU";IF(B2:B="",,B2:B&TEXT(COUNTIFS(B2:B,B2:B,ROW(B2:B),"<="&ROW(B2:B)),"-0000"))})
And here is the SKU-assigning formula from A1 of the "Erik Help" sheet:
=ArrayFormula({"SKU";IF(B2:B="",,VLOOKUP(B2:B&C2:C,{'InventoryMaster(Unsorted)'!B2:B&'InventoryMaster(Unsorted)'!C2:C,'InventoryMaster(Unsorted)'!A2:A},2,FALSE))})

Google sheets - copy data from rows to columns with column value condition

I have a sheet where I am getting payment data from customers with date, name and amount. This is transactional data and more rows keep coming to it.
I need to copy that data to a different sheet in columns so that all payments for each customer come in front for their name and all payments in one month appear in total monthly payment.
This sample sheet has the input data sheets of Product and Services and Target is something I need to prepare automatically for all new entries in frist 2 sheets.
https://docs.google.com/spreadsheets/d/1YInJUkCw0TaegYKHVw6JGHKIZ9Wz6xYiOrhcIW2ya64
Welcome Kokab, I suggest to compile with that formula
={"Product/services","Receipt No","Date","customer number","Name","Code","Payment";
QUERY({
ARRAYFORMULA({IF(ISBLANK(Product!A2:A),,"Product") ,Product!A2:F});
ARRAYFORMULA({IF(ISBLANK(Services!A2:A),,"Services") ,Services!A2:F})
},"select * where Col1 <> '' order by Col2")}
then perform a pivot table as following https://docs.google.com/spreadsheets/d/19dj_A1pYm5pLqb_S69EdBfn_C3K43CanL7qPDuZLDY8/edit?usp=sharing

How to track Indian Mutual Funds using Google Sheets and update the price automatically

Looking to manage the mutual fund portfolio, and automatically update the price so the portfolio always shows the correct information.
I have tried to use Google sheet functions like
INDEX
SPLIT
VLOOKUP
IMPORTDATA
=IMPORTDATA("https://www.amfiindia.com/spages/NAVAll.txt")
=INDEX(SPLIT(VLOOKUP(A2&"*",NAV!$A$1:$A$20501,1,false),";"),,5)
The outcome of this is to create a portfolio with an automated price update.
You can easily use GOOGLEFINANCE APIs to do this. Suppose you want to track price of SBI Magnum Taxgain Scheme Direct Growth.
You can do this in the following steps:
Go to Google Finance.
Get the Google Finance Ticker symbol or Stock Id for the fund. For example:
MUTF_IN:SBI_MAGN_TAX_VQNUL5 for SBI Magnum Taxgain Scheme Direct Growth.
In a new Google Sheet use the following method to get current price of the MF.
=GOOGLEFINANCE("MUTF_IN:SBI_MAGN_TAX_VQNUL5")
For example see:
Medium Article
video tutorial
sheet
Create a spreadsheet on Google Spreadsheets. Name the spreadsheet as you need.
Let us create a sheet and name the sheet as "NAV". This sheet will hold all the latest NAV and will be updated with the latest price automatically. Let us visit this sheet later for automating the price update.
Now, let us create a new sheet, call it "Portfolio".
Create columns in the 1st row as follows:
AMFI Scheme ID
Account Number
AMC
Scheme Name
Unit Balance
Cost - Dividends
Value
Returns
Return (%)
AV Cost / Unit
NAV
NAV Date
Let us shift the tab to "NAV". In the column, A1 enter the formula as
=IMPORTDATA("https://www.amfiindia.com/spages/NAVAll.txt")
This will update the NAV automatically and we will use this data to update information in our portfolio. This will have the following columns now:
Scheme Code
ISIN Div Payout / ISIN Growth
ISIN Div Reinvestment
Scheme Name
Net Asset Value
Date
Now find the scheme you have invested in from the NAV tab and get the Scheme Code and copy to AMFI Scheme ID column on "Portfolio" sheet. Similarly, you can copy the Scheme Name.
Get your statement from the AMC and update the Unit Balance, Cost - Dividends columns.
In the "Portfolio" sheet enter the formula against NAV
=INDEX(SPLIT(VLOOKUP(A2&"*",NAV!$A$1:$A$20501,1,false),";"),,5)
In the "Portfolio" sheet enter the formula against NAV Date
=INDEX(SPLIT(VLOOKUP(A2&"*",NAV!$A$1:$A$20501,1,false),";"),,6)
Value column is the product of Units x NAV
Returns are Value-(Cost-dividends)
Return % is Returns / (Cost-dividends)
AV Cost / Unit is (Cost-dividends) / Unit Balance
Now create a summary line in the bottom for Cost-Dividends, Value, Returns and Return %
Voila! Your portfolio will be updated automatically when you open the spreadsheet. Just ensure you update unit balance and cost-dividends for accurate computations.
Most of the stocks and mutual funds are available via Google Finance API which Rishabh's answer explains clearly.
But Google finance doesn't have data for many Indian mutual funds like Axis Blue Chip Direct plan - Growth, Parag Parikh Flexi Cap Fund Direct Plan-Growth, etc.
Suresh's answer is a different yet effective way to add NAV and other details into google sheets but that formula is outdated and it no longer works in google sheets. So, I am answering this question with the new tested approach.
Steps to get the NAV for any mutual fund not present in Google Finance
As Suresh mentioned, create two sheets. One for portfolio and the other for NAV
In the first cell of the NAV sheet, enter the formula as
=IMPORTDATA("https://www.amfiindia.com/spages/NAVAll.txt")
Now, search for the mutual fund, I'm taking Axis BlueChip fund direct growth as an example.
Have a look at this image of Axis BlueChip direct plan growth mutual fund in NAV sheet
Note the row number for the mutual fund and in our case, it is 5507
Notice how the value is separated by ";" delimiter and we need to get NAV which is on 5th position (or column if separated by a delimiter)
To get the NAV value extracted from the specified row number of NAV sheet in the portfolio one, do the following
=INDEX(SPLIT(NAV!$A$5507,";"),5)
Breaking down,
NAV!A$5507: It means, we're extracting row number 5507 from the NAV sheet
SPLIT(NAV!$A$5507,";"): Since, the delimiter is ";", we're splitting it on ";" which will give us 5 columns (If you're confused, look at NAV sheet data again. There are a total of six fields Scheme Code, ISIN Div Payout/ ISIN Growth, ISIN Div Reinvestment, Scheme Name, Net Asset Value, Date)
=INDEX(SPLIT(NAV!$A$5507,";"),5): After splitting, we're choosing the 5th column which is NAV and that's how the above function works and we get the NAV value of the fund automatically.
Once, we get the NAV value, we can add the quantity and buy avg value of our stock/mutual fund in another column of the portfolio sheets
Then, with a simple operation, we can get the total value of our investment in sheets.
For example,
=(E6-C6)*B6
Cell E2 : Updated NAV price
cell C2 : Buy average price
Cell B2 : Quantity
I'd like to acknowledge my friend Abhilash who taught me to manage my stock portfolio by Google Sheets.
For the whole list of Schemes and their latest NAV try the following:
First row:
A1 = Scheme Code
B1 = ISIN Div Payout/ ISIN Growth
C1 = ISIN Div Reinvestment
D1 = Scheme Name
E1 = Net Asset Value
F1 = Date
In B2: paste the following:
=ArrayFormula(SPLIT(FILTER(IMPORTDATA("https://www.amfiindia.com/spages/NAVAll.txt"),isnumber(left(IMPORTDATA("https://www.amfiindia.com/spages/NAVAll.txt"),2)*1)=true,IMPORTDATA("https://www.amfiindia.com/spages/NAVAll.txt")<>""),";"))

Autofill a column in Google Sheets as new rows are submitted through Google Forms

I have a google form that has fields taking up 7 columns in the response sheet. I have reserved the 8th column to compute few fields (basically a formula) and generate a unique ID for that response. I know that when new responses are added, I can drag the box of the 8th column field all the way down to the given number of rows to auto-fill the column. But this type of auto-fill requires a manual effort. What I want is an automated system to keep filling in the column with my formula.
I have tried pulling the column down beyond the current number of rows in a hope for it to auto calculate when the new row is added but a new response simply overwrites the entire row instead of filling in just the seven columns which deletes the 8th column in that row.
The spreadsheet is
https://docs.google.com/spreadsheets/d/1HM2dDRtkF_KlQ8SKoeW2YmjP2dttYAk1_4iCYBVEN8o/edit?usp=sharing
The responses fill up to column H (Member #3) and my desired column is column I (Registration ID) which is aided by column J, K and L.
You can try using
=ARRAYFORMULA(IF(ROW(M:M)=1,"Registration_ID",IF(C:C="UM-DAE CBS, Mumbai", "cbs"&"_"&J:J, IF(C:C="ICT, Mumbai", "ict"&"_"&K:K, IF(C:C="IISER, Pune", "iiser"&"_"&L:L,"waiting for a response...")))))
Just some explanation:
//This one is just to label the first row as Registration_ID so you can replace M:M with any column you want.
IF(ROW(M:M)=1,"Registration_ID"
My first time answering in Stack Exchange so I'm not familiar with the formatting.
Also a heads up, if you wanted to use ArrayFormula() with an If(AND()) or If(Or()) function, just know that the ArrayFormula() requires you to use arithmetic functions like "*" or "+" instead.
So IF(AND(A,B)) will be IF(A*B).
Use the "CopyDown" add-on for Google!
On your Google Sheet that your Form posts to, click Add-Ons > Get Add-Ons > type "copyDown".
This add-on quickly & easily allows the sheet to automatically copy the formula from one of your top rows (adjustable) to the rest of the form's submissions.
Love it!

Attempting to Query only data from cells that are not blank

I have a google spreadsheet with 2 sheets. The first sheet contains data that has been input by a form. Each form response will input data for the following "Timestamp", "Zone", "NPC", "Faction", "Amount", "Faction2", "Amount2", "Faction3", "Amount3", "Faction4", "Amount4", "Faction5", "Amount5".
Row 1 contains the above category names for each response input. The way the form works unfortunately is that each response is put into it's own column based on what Zone is chosen at the beginning as each Zone has different possible responses for the category. So the data is spread out from Columns C to Columns HC. Each row will only have one response per category name, but the category names are repeated and spread out.
I have been using the following query in Sheet2 to pull the information from whichever "Zone" that is selected from the E1 dropdown in the sheet.
=if(len(E1)=0,"Please Select a Zone in E1",query('Form Responses'!A2:IS,"Select * Where B = """&E1&""" "))
The problem is that it returns the entire Row for the Selected zone so the following information doesn't line up. Is there any way for me to return only the information from the Rows that have data in the cell. This would then line up the data into the correct Column for Sheet2
Below is a link to the Form with some sample data in it, the Cobalt Scar selection lines up as the responses are in the corresponding columns in the data sheet, but Crystal Caverns and Western Wastes do not. You can change selected zone to view the results in Sheet2 E1.
Also the sheet is a copy and can be edited by the public.
https://docs.google.com/spreadsheet/ccc?key=0AqEFpZnTydP-dFNNOV9sRzNRSldDUXRJX1pqSFZRYkE&usp=sharing
I haven't found an elegant solution to this type of problem, but that doesn't mean it's not solvable.
The solution I created on your sheets is easily manageable (only have to update the sheet with the area / column table), but it does take up a little more memory.
How it works:
The ArrangedData tab is the first 2 columns from Form Responses, then the "appropriate" columns (based on the selection made on sheet2; it picks the columns from a lookup on sheet5).
Then ArrangedData is filtered (based on the selection on sheet2 again) into sheet2.
Let me know if you have any questions about it.

Resources