Using Vlookup inside array formula in Sheets - arrays

I have two sheets with relevant columns:
Confirmed Cards
a. Email
b. Credits
Purchase Credits.
a. Email
b. Rolling Total Credits
I'm hoping to populate "Credits" inside of "Confirmed Cards" with "Rolling Total Credits" from "Purchase Credits" by cross-referencing emails to show how many credits a user has.
I'm hoping to do this within an Array Formula, so as users are added to my database within confirmed cards, the amount of credits they own are automatically updated.
This is what I am currently using within "Confirmed Cards" to try to pull in the amount of credits the user has:
=ArrayFormula(VLOOKUP(A2:A,'Purchase Credits'!A2:F,5))
The formula correctly inputs the correct amount of credits for A2, the first user email, however, it inputs this value into every single row, regardless of email. For example, if alex#gmail.com has 100 credits, this amount shows for every single row within "Credits."

you will need 4th vlookup parameter. try:
=ARRAYFORMULA(IFERROR(VLOOKUP(A2:A, 'Purchase Credits'!A2:F, 5, 0)))

Related

what am i supposed to do in this situation?

so recently my principal is having me create a database for a tardy system recently what i've done is set up a google form where the student id can be enter through a num pad and put into a google sheet where ive setup 2 sheets one where it shows the student name and how many tardies they have and then the other is the google form responses, each tardies cell in the other sheet has the formula: =COUNTIF('Form Responses'!B:B,"") which essentialy checks the number of times a certain student id pops up, by ferpa i am not legally allowed access to the student id's is there any possible way i can maked it when a person enters their student id it adds/creates a new formula for the tardies cells to check through the entire list without a duplication or error code?
i have tried the =COUNTIF('Form Responses'!B:B,"") formula but that would make where my principal would have to edit a thousand lines of formula
Depending on the exact setup of your sheets, you can use a formula like this, guessing that the students' IDs are in A column:
=BYROW(A2:A,LAMBDA(each,IF(each="","",COUNTIF('Form Responses'!B:B,each))))
That would set a formula will drag all the column automatically.
Or, instead of having a list of IDs you can set a QUERY that will find all the ID values in the responses and their count:
=QUERY('Form Responses'!B:B,"SELECT B,Count(B) where B is not null group by B")

How to solve Google sheets formula issue

Hoping someone here can help with a small issue.
I'm writing an array formula, which uses a vlookup to pull prices. Identical items can be either on the sales floor, or in various overstock locations, and since they gradually increase in value, only the price attached to the version thats on the sales floor should be valid. Vlookup unfortunately pulls the price for the first match it finds.
I've cannibalized the following code from various sources online, and it does work at pulling the correct prices, however, it appends "Sales floor" to every price.
Is there something I'm missing, or a way to further refine it?
={"Variant Price";if(Checkbox!B1=TRUE,Arrayformula(IFERROR(VLOOKUP(A2:A&"Sales Floor",Inventory!A2:K&Inventory!N2:N,Column(J2:J),false))),"")}
The variant price and checkbox portions are simply to add a title, and to be able to control whether the formula is activated, this sheet has a large number of formulas that don't need to run constantly.
try:
={"Variant Price"; IF(Checkbox!B1=TRUE,
ARRAYFORMULA(SUBSTITUTE(IFERROR(VLOOKUP(A2:A&"Sales Floor",
Inventory!A2:K&Inventory!N2:N,Column(J2:J), 0)), "Sales Floor", )))}

Splitting Multiple Ranges from a Single Range in Google Sheets

I am building a scheduling tool for my company. The structure of my Google Sheets document is a summary page with the entire schedule laid out for each employee in each department. Then, each employee gets their own sheet. In each employee sheets I have a section for Sunday, Monday, and Tuesday (the days each employee works). In each section by day I have a column indicating the hours they are on the clock, and then a column for each department. I have placed a checkbox into each cell and can activate the check box to indicate that this employee will be working in that department at that corresponding time. However, there are times when an employee is in a department more than once per day, meaning that the column with the checkboxes has, for example, checks in the cells corresponding to 7am-10am and 2pm-5pm, with unchecked boxes in the cells corresponding to 11am-1pm.
I have query functions that can pull the start and end times in that department if the employee is only in that department once per day. The output, after some concatenation, is something like "7AM-2PM".
=QUERY(A4:C17, "Select MIN(A) where (C=TRUE)")
=QUERY(A4:C17, "Select MAX(A) where (C=TRUE)")
However, I cannot think of a way to discriminate multiple start and end times. Using the above example, I'd like my output to be "7AM-10AM" and "2PM-5PM". These can be in separate cells or the same cell, doesn't make a difference to me. There can also be formulas in several cells if a subsequent formula needs to operate off a previous one.
I hope this makes sense in the way I have described it. I have been struggling for weeks trying to come up with something and am running out of time. Thanks for any and all help!
try:
=ARRAYFORMULA(IFNA(TEXTJOIN(CHAR(10), 1,
TEXT(FILTER($A4:$A17, IF((B4:B17=TRUE)*({FALSE; B4:B16}=FALSE), 1, )=1), "hh:mm\ - ")&
TEXT(FILTER($A4:$A17, IF((B4:B17=TRUE)*({B5:B17; FALSE}=FALSE), 1, )=1), "hh:mm"))))

Can you create dynamic formulas in Google Sheets?

So I'm just starting out creating a portfolio tracker within Google Sheets. I'm using the Google Finance methods to get the stocks name and all the relevant data that I need. The only issue is that I can't figure out how to populate the specific data I need without having to manually type out the same formula's for each stock I want data for.
For example... Each row in the first column would contain the ticker symbol for that specific stock. If I bought a new stock, I would just type in the ticker symbol in cell A1 and this would populate the necessary fields such as price and so on. If I bought another stock I would essentially do the same thing but now in A2.
I know that you can get the price of a stock by doing
=GOOGLEFINANCE(A1, "price")
but is there any way to make it dynamic? something like:
=GOOGLEFINANCE(A(Row(ref)), "price")?
Any suggestions would be helpful. Maybe there's even an addon that makes this process simpler, but I'm not sure.
try:
=ARRAYFORMULA(IFERROR(GOOGLEFINANCE(A1:A10, "price")))
You just have to write the function for A1:
=GOOGLEFINANCE(A1, "price")
And then drag the little square on the cell down. It will automatically pick up the correspondant number of the row in the A column.
You can set-up your sheet to have like 100 rows used, and when you add the ticker it will automatically calculate it.
If you don't want th #N/A to show you can do it like:
=IFERROR(GOOGLEFINANCE(A1, "price"))

Calculating dynamic pricing on Google Sheets

I have imported data from a trading exchange listing sellers of a particular cryptocurrency.
From this data, I want to create dynamic pricing to display an average cost on an order based on given order size.
I will give an example of what I am looking for:
Example dataset
Within this example, we would be purchasing the cryptocurrency 'SINS'. As per the data showed on this table, if 29.06 SINS was purchased, that would fill the first order, and the total BTC paid would be 0.00459 BTC.
If an order was placed for 145 SINS, it would fill the orders up to row 12 and partially fill the order in row 13. By calculating that manually, I know that would cost 0.02293365 BTC (calculated using col D) at an average price of 0.00015816 per SIN.
What I would like to achieve is if a number is entered in a cell, it confirms the average price of an order based on the number entered and the orders imported from the trading exchange.
=INDIRECT(ADDRESS(MATCH(VLOOKUP(O2,F2:F,1),F:F,0),7,4))+(
INDIRECT(ADDRESS(MATCH(VLOOKUP(O2,F2:F,1),F:F,0)+1,4,4))*(O2-
INDIRECT(ADDRESS(MATCH(VLOOKUP(O2,F2:F,1),F:F,0),6,4)))/
INDIRECT(ADDRESS(MATCH(VLOOKUP(O2,F2:F,1),F:F,0)+1,3,4)))
spreadsheet demo

Resources