dynamically change column in excel sumifs - excel

I have created a dynamic table in excel through a SUMIFS formula:
=SUMIFS(data!$D:$D,data!$B:$B,Sheet2!B$3,data!$C:$C,Sheet2!B$2,data!$A:$A,Sheet2!$A4)
this is what the table looks like:
while the data looks like:
Now I am picking values from the column Order Total. What I would like to do is to insert a dropdown list on cell B1 to dynamically select from what column I want to get the data.
Is there a way to add this in my formula?

Ok, since order total is in column D, I'll replace the first piece of the sumifs with the indirect, and I'm assuming the data is on the data worksheet, as well as cell B1 which you want the dropdown: =SUMIFS(indirect("data!$"&data!B1&":$"&data!B1),data!$B:$B,Sheet2!B$3,data!$C:$C,Sheet2!B$2,data!$A:$A,Sheet2!$A4)
What the indirect does is concatenate (using the '&' symbol) the string information with the cell information, then change it to a cell reference. If you copy everything within the indirect into another cell (preceded by "="), it would return your original data!$D:$D, if you put "D" in cell B1. This then becomes the cell references for the sumifs formula when using the indirect formula. If you change cell B1 on the Data worksheet to "E", the formula would evaluate to data!$E:$E within the indirect, which would then mean the sumifs formula references column E.

Related

How to reference an entire column from one cell in a spreadsheet function

I am looking for a way to accomplish the following using spreadsheet formulae: the output in cell D5 should be the array from cell B5 to the last populated cell (assume the range is contiguous). Thus if text were typed into cell B10, the output would automatically expand.
However, I want to avoid the volatile OFFSET and INDIRECT functions.
So I have this formula in cell D5:
=UPPER(B5:INDEX(B:B,ROW(B5)+COUNTA(B5:INDEX(B:B,ROWS(B:B),,1))-1))
but this is unsatisfactory as it references the B:B column.
In effect I want a construction that returns me B:B given the cell B5 ie the equivalent of =INDIRECT("C" & COLUMN(B5),"FALSE"), but in a non-volatile format.
Any suggestions?
NB. I don't have the very latest Excel. I have LET, SEQUENCE, FILTER etc, but not LAMBDA and the functions that came with it (ie I can't do recursive LAMBDA calls).
Make column B data into a table
the content of cell D5 can then be dragged to a different location, without the formula results changing.

Find the Last Cell Value of the 2nd Column Set for each 1st Column Cell in EXCEL

I have the following structured table in excel where 1000s of rows included.
I want to return the Last Cell Value of Column B for Each value in Column A.
For example:
For Cell A1 -> I want to return the Cell B5.
For Cell A6 -> I want to return the Cell B9.
I have tried with VLOOKUP, HLOOKUP, INDEX likewise so many formulas where I ended with more conflict situations. Can anyone please write down a Formula to give my requirement a life?
Array formula (Press Control + Shift + Enter while entering the formula) in cell C1 and copy it down.
=IF(A1="","",IFERROR(INDEX($A2:$B$20,MATCH(FALSE,ISBLANK($A2:$A$20),0)-1,2),LOOKUP(2,1/(B2:$B$20),B2:$B$20)))
if you don't mind using column C as a helper column you could use something like that:
If you won't use Array formula you can Use this solution:
like this image:
use column C as helper with this formula in first cell =OFFSET(A1;SUMPRODUCT(MAX(($A$1:$A1<>"")*(ROW($A$1:$A1))))-ROW(A1);0)
and use this formula in column D's first cell =IF(A1="";"";INDEX($B$1:$B$13;SUMPRODUCT(MAX((ROW($A$1:$A$13))*($C$1:$C$13=A1)))))
and copy fill-down to all cells.
Try this shorter, without helper column and non-array formula solution
In C1, formula copied down :
=IF(A1="","",INDEX(B1:B$9,MATCH(1,FREQUENCY(1,0+(A2:A$9<>"")),0)))

Use cells to fill in the filepath for a SUMPRODUCT formula?

I am creating a SUMPRODUCT formula with a nested SIGN formula which helps to set criteria for which I want figures to be pulled from (similar to SUMIF or SUMIFS). Is there a way to have part of the formula refer to a cell/column that has a string, which is used to make up the filepath?
See below the example code.
=SUMPRODUCT(SIGN((
'S:\Folder\[File.xlsm]Range-97-98'!$B$5:$N$5
=
B$7
))*((
'S:\Folder\[File.xlsm]Range-97-98'!$B$423:$N$423
)))
The worksheet "Range-97-98' as you can see is a short Year range. This is because the current row the Sumproduct formula is on is a row assigned for 1997-98 (cell A9 = "1997-98")
Is there a way to change that Worksheet in the filepath based on the trimmed cell value from A column? eg. A10 is "1998-99" therefore the SUMPRODUCT would be Range-98-99'!..., and A11 is "1999-00" and so on.

Excel: count values on another sheet with dynamic column reference

I have a simple formula in cell B7 of a sheet called Summary Stats that references a sheet called Rolling Returns Data:
=COUNT('Rolling Returns Data'!C$11:C$17202)
I want to be able to dynamically reference the column in the formula i.e. I have letter C in cell B1 of the Summary Stats sheet and want to be able to replace the reference to column C in the formula with a reference to cell B1, so that if I then change the formula that calc. that is then being performed is:
=COUNT('Rolling Returns Data'!D$11:D$17202)
As Scott Craner suggested, use INDIRECT.
=COUNT(INDIRECT("'Rolling Returns Data'!"&A1&"$11:"&A1&"$17202"))
Now you just have to put the letter of the column you want to reference. You can of course change the A1 reference to anything you'd like. Or you can change the code to the following
=COUNT(INDIRECT("'Rolling Returns Data'!"&A1))
and use A1 to specify the address of your column, in this case "C$11:C$17202".
If you're ok using column numbers rather than column letters then this non-volatile formula will work:
=COUNT(INDEX('Rolling Returns Data'!1:17202,11,$B$1):INDEX('Rolling Returns Data'!1:17202,17202,$B$1))
If you really want to use column letters then you can turn a column letter into a column number using:
=COLUMN(INDIRECT($B$1 & 1))
But then you lose the non-volatile nature.
Edit:
If you use the column numbers and leave B1 blank it will return the count of all columns.

Excel string to criteria

I have an Excel formula like this:
=SUM(SUMIF(A2:A11;{"1010";"1020"};B2:B11))
Now I need to make the formula more dynamic. Instead of changing the formula itself, I should be able to change some cell (linked in the formula). This change will be reflected in the formula.
Ex:
=SUM(SUMIF(A2:A11;D2;B2:B11))
Cell D2 should return something similar to {"1010";"1020"} in the first formula.
I tried this and it works only if in the column D I have one value (ex: 1020), but if there are two values (ex: 1010;1020) it returns 0.
This is how my table looks like:
As you can see, it shows 0 for the cell where D2 has two values; but it works when there is only one value. All the rows in column D will be like cell D2, with 2 or more values, this is why it has to be dynamic using a list in the formula.
How can this be achieved in Excel? How can I make a list from the cell?
Using multiple cells would be easier! If the formula cell is one to the right of the criteria cell, you can define a named formula (Using Name Manager) called, say, GetList, which refers to this formula:
=EVALUATE("{"&INDIRECT("RC[-1]";0)&"}")
Then your formula becomes:
=SUMPRODUCT(SUMIF(A2:A11;GetList;B2:B11))

Resources