Multiple IFERROR commands not working between 2 sheets - excel-2010

I am trying to create a proper function code in excel 2010 that allows information from a schedule (4 days) to flow to a main schedule depending on the date. 'Main' page (sheet 1) has E1 pulling current date directly from computer. 'Beauty Shop' page has manually entered date in B3, D3, F3 and H3 and if the dates match the information from A& B5-24, C&D5-24, E&F5-24, G&H5-24 respectively are suppose to pull to the main schedule. At this point A&B will pull but when the other columns (D3, F3 and H3) have the matching date to main E1 the information from C&D5-24, E&F5-24, G&H5-24 will not pull ... Here is what we entered
=IFERROR(IF(AND($E$1='Beauty Shop'!$B$3,'Beauty Shop'!A5>0),'Beauty Shop'!A5," "),IFERROR(IF(AND($E$1='Beauty Shop'!$D$3,'Beauty Shop'!C5>0),'Beauty Shop'!C5),IFERROR(IF(AND($E$1='Beauty Shop'!$F$3,'Beauty Shop'!E5>0),'Beauty Shop'!E5),IFERROR(IF(AND($E$1='Beauty Shop'!$H$3,'Beauty Shop'!G5>0),'Beauty Shop'!G5)," "))))
Any suggestions as to why the other 3 functions are not pulling the information to the main schedule??
Here is a link to what we have so far ...This one should work...If you open it with Zoho sheet it will show all formulas and how we set everything up at this point.
https://drive.google.com/file/d/0B_wFNip-EvKdaXhVRDlnQzdQUzQ/view?usp=sharing

Ok, so I'm not 100% certain I understand what you're after but let's see if this helps...
From the spreadsheet you uploaded, and assuming you're referring to the formula in A47 on the main sheet...
=IFERROR(IF(AND($E$1='Beauty Shop'!$B$3,'Beauty Shop'!A5>0),'Beauty Shop'!A5," "),IFERROR(IF(AND($E$1='Beauty Shop'!$D$3,'Beauty Shop'!C5>0),'Beauty Shop'!C5),IFERROR(IF(AND($E$1='Beauty Shop'!$F$3,'Beauty Shop'!E5>0),'Beauty Shop'!E5),IFERROR(IF(AND($E$1='Beauty Shop'!$H$3,'Beauty Shop'!G5>0),'Beauty Shop'!G5)," "))))
LibreOffice's helpful formula editor shows the following for the start of your expression tree...
Let's ignore the IFERRORs for now and look at your first IF...
IF(AND($E$1=$'Beauty Shop'.$B$3,$'Beauty Shop'.A6>0),$'Beauty Shop'.A6," ")
In short...
If Main's E1 (Today's date) = Beauty Shop's B3 AND Beauty Shop's A6 is more than 0 (A time other than midnight), Return the value of Beauty Shop's A6 (The time). Otherwise, return an empty string.
The second IF block will only be executed if the first one errors, not if it returns false.
So the simple fix is to remove the blank string and move the following blocks up one level.
At the very least, make sure your strings aren't empty while debugging - it will make it a lot easier to track where your logic flow ends up.
EDIT: I previously said you could do this with a single IFERROR but that was incorrect.
Hope that helps a little
A simpler approach...
Let's use some hidden cells for some intermediate values to represent which data to pull.
Put the following formulae in Main.H1:K1:
=IFERROR(IF(AND($E$1=$'Beauty Shop'.$B3,$'Beauty Shop'.A5 > 0), 1, 0), 0)
=IFERROR(IF(AND($E$1=$'Beauty Shop'.$D3,$'Beauty Shop'.C5 > 0), 1, 0), 0)
=IFERROR(IF(AND($E$1=$'Beauty Shop'.$F3,$'Beauty Shop'.E5 > 0), 1, 0), 0)
=IFERROR(IF(AND($E$1=$'Beauty Shop'.$H3,$'Beauty Shop'.G5 > 0), 1, 0), 0)
These cells will now contain a 1 or 0 indicating the values should be populated. You can repeat these down the page.
The reason to do this is that there are 2 cases resulting in a 0 (No data and an error) so doing it all in one go would either require repeating the ELSE branch multiple times or doing some maths with the resulting values (which works and is concise but is very hard to follow/maintain)
Then your formula for Main.A47 becomes...
=IF(H1, $'Beauty Shop'.A5,IF(I1, $'Beauty Shop'.C5,IF(J1, $'Beauty Shop'.E5,IF(K1, $'Beauty Shop'.G5,""))))
See below for how today's value is matching (K1 is a 1) which has caused it to pull a record from the Beauty shop page.
Hope that's clearer?

Related

Google Sheets formula that queries recurring data based on time interval/frequency

I'm trying to have a calendar display a series of activities based on their type, time and frequency for an easier visualization of data.
So far, I have managed to create a formula that correctly fetches the data that I have on a repository and displays it on the calendar. However, I'm not sure how I can have it account for entries that have a frequency (happening every x days).
For an easier understanding here are screenshots of both the table and the schedule
And here's the current formula I'm using to display the event/activity title in each day/hour at C12 for example:
=IFERROR(
INDEX(Repository!$K:$K,
MATCH(
C$10,
IF(
(Repository!$G:$G=$G$8)*
(Repository!$H:$H=$K$8)*
(Repository!$N:$N>=$B12)*
(Repository!$N:$N<$B12+TIME(2,0,0)),
Repository!$D:$D),
0)
),
"")
What I'm currently missing on the formula is a way to correctly account for the start/end date as well as frequency and understand if each day falls under the specified criteria. In case the frequency is 0 then I'd like to have it discard the end date at all (in case for some reason I end up forgetting to set the end date).
I have tried to work with the formula provided to account for the frequency but nothing that I tried seemed to work.
Minimal example
Entry on the table with a 2 days frequency:
Expected result on the schedule:
So basically, the formula on each cell should check for the start date, end date and frequency of the activity and identify if the specific date on the schedule falls under the specified timeframe.
In this minimal example, the activity starts on the 7th December and repeats every 2 days until the 14th of December.
Feel free to duplicate the spreadsheet here:
https://docs.google.com/spreadsheets/d/19h0v3XjDqa_DWSx-QBGBNwFGd550a_D3DVFovs5s2qo/edit?usp=sharing
I have tried to build the formula in multiple ways but I can't seem to make it count for the time frequency so that cells recognize this and display the activity in any other dates besides the initial one.
delete all your formulae and use this in C6:
=INDEX(IFNA(VLOOKUP(TEXT(C4:P4+B6:B14, "e-m-d-h-m")&G$2&K$2, SPLIT(FLATTEN(MAP(
Repository!D$4:D, Repository!O$4:O, Repository!P$4:P, Repository!N$4:N,
Repository!G$4:G, Repository!H$4:H, Repository!K$4:K, LAMBDA(d, o, p, n, g, h, k,
IF(DAYS(o, d)>=SEQUENCE(1, MAX(DAYS(o, d)), 0, p), TEXT(d+SEQUENCE(1,
MAX(DAYS(o, d)), 0, p)+IF(ISODD(HOUR(n)), (HOUR(n)*"1:00")-"1:00", HOUR(n)*"1:00"),
"e-m-d-h-m")&g&h&"×"&k, )))), "×"), 2, )))
then copy C6 and paste in C18, C30, etc.

Compare two tab's headers, copy column below maintaining blank columns

I have two tabs, one with all of my column headers (data tab), the other tab with less headers, but all from the data tab.
I want to search the headers of the "data" tab using the headers from the second tab starting at column I through BI. The second tab's headers will periodically change but always be present in the data tab. If the search criteria isn't present, I want to leave that column blank. If it is present, return the values below from the data tab.
I've tried a few formulas, but can't quite get what I'm looking for.
This formula worked to find the data:
'FILTERED'!I2
=FILTER(data!I2:AK,COUNTIFS($I$1:$1,data!I1:AK1))
This formula got the placement right, but produced the wrong information:
'Copy of FILTERED'!I3
=ArrayFormula(IF(ISBLANK(I2:2),,FILTER(data!I2:AK,COUNTIFS($I$1:$1,data!I1:AK1))))
Here's my sheet.
You've got a large range to process, so there may be a slight delay filling the grid by formula (2 or 3 seconds maybe). But I have added a sheet ("Erik Help") with the following formula in I2:
=ArrayFormula(IF(ROW(A2:A),IFERROR(VLOOKUP(ROW(data!A2:A),{ROW(data!A2:A),INDIRECT("data!I2:"&ROWS(data!A:A))},HLOOKUP(FILTER(I1:1,I1:1<>""),{data!I1:1;SEQUENCE(1,COLUMNS(data!I1:1),2)},2,FALSE),FALSE))))
Honestly, it's hard to explain how this works, but I'll try to cover the basics.
=ArrayFormula(...)
This just means the formula will be processing a range rather than one cell.
IF(ROW(A2:A), ... HLOOKUP(FILTER(I1:1,I1:1<>""),{data!I1:1;SEQUENCE(1,COLUMNS(data!I1:1),2)},2,FALSE) ...)
IF(ROW(A2:A) is important, because it signals to do something for every row, thereby creating a 2D grid instead of just processing the current row. The HLOOKUP will look up every header in I1:1 that isn't blank [FILTER(I1:1,I1:1<>"")], which as the sheet is now, will be all of them. They will be looked up in in a virtual array formed from a top row consisting of all headers in data!I1:1 over a bottom row made up of a SEQUENCE of numbers made of 1 row and the same number of columns as are in data!I1:1, starting at the number 2 and moving up. (It starts at 2, because part of the VLOOKUP virtual array which I haven't explained yet, will be forming a column 1.)
VLOOKUP(ROW(A2:A),{ROW(data!A2:A),INDIRECT("data!I2:"&ROWS(data!A:A))}, *the HLOOKUP RESULT NUMBER*,FALSE)
Now a VLOOKUP will kick in. It will look up every row in data!A2:A within a virtual array made of two columns; the first column will be those same row numbers, and the second will be everything from data!I2 over and down (the INDIRECT setup allows this to be a dynamic grid in case you add or delete columns later). As to which column from that should be returns, that will pull from the HLOOKUP results explained above (which, as you'll recall, will all match the headers).
Finally, IFERROR(...) will return null if any step in that process returns an error, which would be because something wasn't found.
see:
=ARRAYFORMULA(QUERY(VLOOKUP(ROW(A2:A), {ROW(A2:A),
A2:C},
MATCH(HLOOKUP(E1:G1,
{E1, F1, G1;
B1, A1, C1},
2, 0), A1:C1, 0)
+1,
0),
"select *"))
for missing headers:

Why will my Google Sheets formula only look to the right?

I'm trying to set up a conditionally formatted training record. I have a separate sheet that shows job titles and X's for required training. Because conditional formatting cannot reference other sheets, in the actual training record I copy the previous sheet (=Sheet1!A1). In the record, there's a drop-down to select job function.
My formula works, but only for the current column and to the right. Column 1 will work for any column (job title), but column 3 can only read job titles on column 3+.
I've tried moving the source data to the right (so the job titles copied from the first sheet start at BB300 instead of B300) but it has the same issue. Locking down the column letter with $ screws up the formula.
=if(AND(B3="",OR(AND(B$2=B$300,B301="X"),AND(B$2=C$300,C301="X"),AND(B$2=D$300,D301="X"))),True,False)
Sample copy of sheet https://docs.google.com/spreadsheets/d/1q0ImPv7FAeDNgz_adOyedcmA2RCot-UzI7nBByMWNiM/edit?usp=sharing
This is a shortened version of the code I'm using, but the idea is that B2 is the job title for the first person, C2 is the job title for the second person, etc. The script checks to see if the job title in B2 matches B300 (the copied requirements from sheet 1) and if so, checks if there is an X. If so, the cell colors (due to the conditional formatting being true) unless there's an X in the cell to show training is completed.
This works appropriately for the first column, but in column 2 (second employee) if I select the job title in column 1 none of the cells flag appropriately (are all blank).
...because conditional formatting cannot reference other sheets...
actually it can. you need to use INDIRECT for that. example:
=A1=INDIRECT("Sheet1!A1")
...to compare if A1 from current sheet Sheet2 is equal to A1 of Sheet1
_____________________________________________________
in your sheet Training Requirements add one row above header row and hide it:
then you can use this custom formula:
=INDIRECT("Training Requirements!"&ADDRESS(3, MATCH(B$2,
INDIRECT("Training Requirements!2:2"), 0), 4)&":"&SUBSTITUTE(ADDRESS(3, MATCH(B$2,
INDIRECT("Training Requirements!2:2"), 0), 4), 3, ))<>B3
spreadsheet demo

Is there a function that can create an expanding array formula that conditionally sums a column based on multiple criteria?

To start, this is my first time posting and so please let me know if I can fix my post in any way to make it easier to answer.
I am trying to create an auto-expanding array formula
I have a sheet with my investment asset mix that including amounts of shares owned of each particular stock, and a sheet that tracks when I receive dividends. My goal is to write an automatically expanding array formula that will sum up the amount of shares that own of a stock on the date a dividend is received and return that value. I have written three different formulas that all accomplish this but none of them will auto-expand as an array.
I'm sure there are a lot of solutions I've overlooked. To boil it down, I need an expanding array formula that will sum the "Shares" column of my asset mix sheet ('Asset Mix'!D2:D, or 'AssetMixShares') conditionally. The name of the stock entered in 'Dividends'!C2:C needs to match the name of the stock in 'Asset Mix'!A2:A (or the named range 'AssetMixStocks'). It then needs to check the dates in 'Asset Mix'!C2:C (or 'AssetMixDates') against the dates in 'Dividends'!A2:A and sum all share amounts where the purchase date is less than (earlier than) the Ex-Dividend Date.
I could probably write some sort of vlookup array on the "Running Total" column -- 'Asset Mix'!E:E -- that would solve the issue, but I'm hoping to eliminate that column. I feel very strongly that what I'm trying to do should be possible without the help of a running total column -- I just don't have the knowledge.
I have tried countless functions and formulas, but the four that I currently have in my example worksheet are SUM, SUMPRODUCT, DSUM, and QUERY.
Attempt 1
SUM and IF
=ArrayFormula(SUM(IF('Asset Mix'!A:A=C2,IF('Asset Mix'!C:C<A2,'Asset Mix'!D:D))))
Attempt 2
SUMPRODUCT
=({arrayformula(SUMPRODUCT(--((AssetMixStock=(indirect("C"&ROW())))*(AssetMixDate<(indirect("A"&ROW())))),AssetMixShares))})
Attempt 3
DSUM
=DSUM('Asset Mix'!A:E,"Shares",{"Date","Stock";"<"&A2,C2})
Attempt 4
QUERY
=arrayformula(query(AssetMix,"Select sum(D) where A = '"&C2:C&"' and C < date'"&(text(year(A2:A),"0000") & "-" & text(month(A2:A),"00") & "-" & text(day(A2:A),"00"))&"' label sum(D) ''",0))
These will all work, as long as I manually drag the formula down, but I want to write some sort of formula that will auto-expand to the bottom of the Dividends sheet.
I have tried to create a Dummy sheet that has both of the relevant sheets. Please let me know if you can access it -- the link is below.
https://docs.google.com/spreadsheets/d/1wlKffma0NJ0KrlWxyX_N20y62azsGpFp3enhmjzJK1Q/edit?usp=sharing
Thanks so much for getting this far and any help you can provide!
We can focus in the first formula to understand a way to make it "self-expandable". As we see it contains references to the cells A2 and C2 in "Dividends" sheet:
=ArrayFormula(SUM(IF('Asset Mix'!A:A=C2,IF('Asset Mix'!C:C<A2,'Asset Mix'!D:D))))
Every time some data appears in these columns (A and C), the formula should work. We can control the presence of the formula by onEdit trigger, if editing is manual. Consider the code:
function onEdit(e) {
var sheet = SpreadsheetApp.getActive().getActiveSheet();
if (sheet.getName() == 'Dividends') {
var row = e.range.getRow();
for (var offset = 0; offset < e.range.getHeight(); offset++) {
sheet.getRange(3, 10).copyTo(sheet.getRange(row + offset, 10));
}
}
}
It checks any modification on the sheet "Dividends" and copies required formula to the modified row(s). This way the formula is expanded for other rows in use.
Well, it's solved! I'll leave this up in case anyone else has the same question.
A kind soul explained the magic of MMULT() to me, and wrote this solution.
=ARRAYFORMULA(MMULT((C2:C=TRANSPOSE('Asset Mix'!A2:A))*(A2:A>TRANSPOSE('Asset Mix'!C2:C)),N('Asset Mix'!D2:D))

Google Spreadsheets - Combining a Filter with Index(Match))... sort of

I've been keeping a log of something for a game which regularly updates. For the most part, I've been handling a lot of it manually and slowly over time I add in some automation to reduce the burden of manual input (and reduce the chance of data entry error).
Specifically, I'm trying to find a way to streamline the process on the following sheet: https://docs.google.com/spreadsheets/d/1nbP0VgXjHozZikZFejERfw_dkilj26pyfhK29uaPAIQ/edit#gid=688163851
How this sheet is set up right now:
I manually enter the "Item Name" when something new is added
I manually enter the "Weapon Type" when something new is added
I manually enter in the "Date" when something new is added and when it returns
The first step I could automate relatively easily with something like this:
=FILTER('DUCAT COST HISTORY'!A2:A,'DUCAT COST HISTORY'!B2:B="Weapon")
The second step could similarly be automated if I added another column to the 'DUCAT COST HISTORY'! sheet which further specified the item.
What I'm having trouble with is how to automate entering the dates on this particular sheet. And the other sheets similar to this one.
The way things work right now is I use a script to grab the new inventory from a .php the developers put together and that information goes in 'TEST SHEET, PLEASE IGNORE'!. After that, the 'DUCAT COST HISTORY'! sheet will automatically update for all existing items, though I still have to manually add new items to the bottom of the list (not a big problem).
What I want is a formula which can look at a range and then return from a different range. Ex.: Let's say I want to look up the "Mara Detron" - I know it's appeared on 7 different dates through the simple use of =COUNTA(F2:2) on the 'DUCAT COST HISTORY'! sheet.
When I try to use INDEX(MATCH()), it's only going to return the value of the cell specified, so I can't use it to check the whole row. The best solution I can come up with is to manually match the item to its respective row and then run the filter like this:
=FILTER('DUCAT COST HISTORY'!F1:1,NOT(ISBLANK('DUCAT COST HISTORY'!F__:__)))`
Where _ would be the corresponding row value.
That's about as far as I got in automating them, though. Is there a way to get the formula to automatically match the corresponding row?
You can use OFFSET with MATCH to get the right row for the filter condition:
=
FILTER(
'DUCAT COST HISTORY'!$I$1:$1,
NOT(
ISBLANK(
OFFSET(
'DUCAT COST HISTORY'!$I$3:$3,
MATCH(A2, 'DUCAT COST HISTORY'!$A$3:$A, 0) - 1,
0,
1
)
)
)
)
This goes in the cell C2 and you just propagate it downwards. To tolerate empty cells you can add IF:
=
IF(
ISBLANK(A2),
,
FILTER(
'DUCAT COST HISTORY'!$I$1:$1,
NOT(
ISBLANK(
OFFSET(
'DUCAT COST HISTORY'!$I$3:$3,
MATCH(A2, 'DUCAT COST HISTORY'!$A$3:$A, 0) - 1,
0,
1
)
)
)
)
)
You were totally right about the chance of data entry error: you've used row 22 instead of row 32 for Prisma Skana. :)

Resources