MEDIANIF using CSE and requires INDIRECT - excel-formula

Constraints:
- There is a Calculation Sheet and a Data Sheet
- Calculation is performed on data existing in the Data Sheet that can have any name; the name is stored in a cell in the Calculation Sheet (e.g., B1).
- Data Sheet has 2 header rows and an indeterminate number of records (i.e., rows that contain data).
- Not all rows contain data, though we have ensured that all data are valid numerical values.
- The particular column holding this data is stored in the Calculation Sheet (e.g., column T).
I know the normal CSE solution works when calculations are performed in the same sheet containing the data, e.g.,
{MEDIAN(IF(A3:A9999 <= 3, A3:A9999))}
Using INDIRECT breaks this approach, however:
{MEDIAN(IF(INDIRECT(B1&"!"&T2&"3:"&T2&"9999")<=3, INDIRECT(B1&"!"&T2&"3:"&T2&"9999"))}
This returns 0 instead of the median of the set of numbers less than or equal to 3.

Try the following formula, which needs to be confirmed with CONTROL+SHIFT+ENTER...
=MEDIAN(IF(COUNTIF(OFFSET(INDIRECT("'"&B1&"'!"&T2&"3:"&T2&"9999"),ROW(INDIRECT("3:9999"))-3,0,1),"<=3")>0,N(OFFSET(INDIRECT("'"&B1&"'!"&T2&"3:"&T2&"9999"),ROW(INDIRECT("3:9999"))-3,0,1))))
Note that the sheet names are wrapped within single quotes in case the names have spaces, as Scott has already mentioned.

Related

Data in column instead of rows

I am getting data from SQL Server into an Excel sheet. Its a customer table containing 20 records. The columns are Customer Code, Customer Name and Customer Short Name.
What I need is instead of data coming in rows (from row 2 to row 21)... it should come in columns.. i.e. 1st three rows of column A contains respective headers (code, name and short name) and column B first row contains value of code, second row value of name and third row value of short name... same continue to column C, D, E..... till all 20 records..
Is it possible in excel?
In Excel, you can easily transpose the array with your data. Consider the following sample data in the range A1:C4:
You could now select the entire range and copy it via CTRL+C -> Paste -> Transpose (T). A second possibility would be to enter the following formula in, e.g., cell E1: =TRANSPOSE(A1:C4). This is a dynamic array formula in the current version (Microsoft 365). If you have an older version, you have to enter the formula as a legacy array formula by confirming the formula with Ctrl+Shift+Enter.
The result is as follows:
Edit: Dynamic setting of range
Theoretically, assuming that the data structure remains the same in terms of the number of columns and rows, the formulaic approach will update the transposed array accordingly as the original data is updated. In the specification above, the range A1:C4 is hard coded. While it is very likely that the number of columns will remain the same (could also be dynamically adjusted), in practice additional rows could be added/deleted from the data. In this case, you can specify the number of rows dynamically, which solves this problem:
=TRANSPOSE(INDEX(A:C,1,1):INDEX(A:C,COUNTA(A:A),3))

Complex INDEX/MATCH? Or VLOOKUP?

I have heard INDEX/MATCH is better to use across the board so I'm hoping this can be done with one of those functions, but I am having a heck of a time figuring it out on my own even though I've tried multiple things. I have a multi-sheet document. It is a list of approved fasteners so there are sheets for washers, nuts, screws, etc. I want to have a separate sheet to look up values based on the nominal size of the required fastener.
A1 on the working sheet will be where the nominal size is entered.
I need it to return multiple values from the washers sheet (we'll start with that one because once I have that, I can figure the rest out) because there will be numerous fasteners with the same nominal size. I also need it to ignore any rows where R exists in column J.
Basically,
If A1 on the working sheet = the value in column F on the WASHERS sheet (the column for nominal size) and there is no "R" in column J on the WASHERS sheet for that row, return the value from column C on the WASHERS sheet.
Use this formula:
=IFERROR(INDEX(A$1:A$14,SMALL(IF((B$2:B$14=F$2)*(C$2:C$14<>F$3),ROW(A$2:A$14)),ROW(1:1))),"")
This is an array formula and must be confirmed with
Ctrl+Shift+Enter.
This is how the formula related to data.

Want a named list with non-continuous cells

I thought this should be a common thing but my search has not returned anything meaningful. I'd prefer an Excel solution, rather than VBA.
I have a proposal sheet with details like number (col D), date etc and a column saying if the proposal got converted (to business).
On the invoice sheet, I have a list of invoices. The requirement is to always refer the proposal number against which this invoice is being raised. For removing human error, the applicable proposal numbers should be available as a drop down. Hence the drop down should only show the proposal numbers against which the invoice can be issued (proposal got converted to business).
This means that non-continuous cells (say, D3, D4, D6, and D10 - where proposal converted is 'yes') from the proposal sheet should be the values available in drop down of data validation in the invoice sheet. How do I achieve this?
Edit:
Adding an image that is representative of the 2 sheets.
My solution involves creating a list using the INDEX MATCH or INDEX SMALL method to pull multiple results from the data that can be used for the dropdown.
I added a couple of extra columns to count the number of times an invoice has been invoiced and then a further Yes/No to make the index formula easier to follow. You'll see that my example only has 2 values to select from as the others have been fully invoiced.
The scary formula in Q1
=IFERROR(INDEX($A$2:$H$1000,SMALL(IF(($H$2:$H$1000="Yes"),ROW($A$2:$H$1000)-1),ROW(1:1)),1),"")
This is an array formula so you must use SHIFTCTRLENTER instead of just ENTER in the formula bar. {} backets will be added if you do it right.
To break it down, INDEX($A$2:$H$1000 is selecting your proposal data and some more rows below (1000). SMALL(IF(($H$2:$H$1000="Yes") is looking at my extra Yes/No column for "Yes". ROW($A$2:$H$1000)-1) is returning the row number minus 1 to account for the fact that our range starts at A2. ROW(1:1) is saying that we want first match in the list and the ),1) returns the vlue in the first column of the range $A$2:$H$1000.
Because ROW(1:1) returns the first result, you will need to autofill down in order to pull more results. As you do this the formula will copy down as 1:1, 2:2, 3:3...ect. I filled down to row 50 to allow for a decent amount of results.
You could set your validation range to Q1:Q50 but then you would have lots of empty space in your dropdown so, have a look at cell R1.
="Q1:Q" & COUNTA(Q1:Q50)-COUNTBLANK(Q1:Q50)
This formula creates a range based on the results in column Q. You can use that value in the data validation range by entering.
=INDIRECT($R$1)
Thus creating the dynamic range that you require.
You don't have to use the extra columns that I added but the formulas are;
=COUNTIF(M2:M1000,A2) to count the number invoiced
=IF(AND(F2="Yes",G2<E2),"Yes","No") to check if it can still be invoiced.
if you do want to use them then I'd recommend formatting your data as a table so that the formulas are copied down automatically on new rows.
Also I'd advise putting the index list on a different sheet so that rows are not deletes etc.

Excel array formula help required - multiple criteria, multiple results

I need help - currently, all of my research on this topic is making things worse.
I have a worksheet with an undetermined amount of data (new data is being added constantly)
From this worksheet I have to collate all valid results that match the criterion of; no data entry in column L, and the data of column A must fall within the current month (I also need the same again but for the month previous... I figure I can easily adjust a single formula...)
Ideally, the returned results should list in a column the data pulled from the source sheet from column B
The results are being inserted into a dashboard page of a different tab within the same workbook.
I really would appreciate a little help.
Say our data is like:
Pick a cell, say M1, and enter the array formula:
=TEXTJOIN(",",TRUE,IF(($L$1:$L$26="")*(MONTH($A$1:$A$26)=3),$B$1:$B$26,""))
where the 3 stands for March:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.

Excel 2007 - Named Ranges

I have a worksheet where data is updated from an external source. The page contains data from today going out 20 days. I have a named range for each column i.e. Today ($D$4:$D$50), Tomorrow ($E$4:$E$50), etc, etc. My issue is that sometime the data from the external source does not contain data so nothing is populated in the columns. However, when there is data being returned again the name ranges are automatically changing i.e , Today changes to ($F$4:$F$50). No new columns are being inserted or deleted.
How can I specify / force the name ranges always to stay the same i.e. Today is always column E, I thought that was the point of the $.
Thanks.
you could try this formulae for your named range formula.
In Name Manager, edit your named range and pop a modified version of the formulea below into the refers to: field.
The modifications will be to the numbers within the address() function. The first value is the row number, the latter is the column number, so Column A = 1, Column B = 2 and so forth.
=INDIRECT(ADDRESS(1,13)&":"&ADDRESS(50,13))
It then uses the indirect function plus a concatentation of the 2 address functions to change formulae to a cell reference that the named range can use.
So the example above, means my named range will go from M1:M50.

Resources