I have a range in excel with dates and values
http://lh4.ggpht.com/_i-hI_3gfy08/SoSIopeZUZI/AAAAAAAABEk/KjFnq57VTUc/table.png
EDIT:image added
I want to select the MAX value from the HIGH column for each YEAR (2009 would return 404, 2008 would return 390)
I've done something similar but it's using SUMIF, not MAX.
Any excel people in here that can help me out?
The equivalent of SUMIF in Excel is something like this:
{=MAX(IF(CategoryColumn="High",ValueColumn,"")}
Where
CategoryColumn is the column containing your categories (e.g., "Low", "Med", "High")
ValueColumn is the column containing the data you want to get the max of
NOTE: This is an array formula so you must press Ctrl-Shift-Enter when entering this formula instead of just Enter. Also, don't actually type in the braces {}. The braces show up automatically to indicate that you've entered an array formula.
NOTE 2: You can actually name a range of data. For example, select the range A1:A20. Right-Click and select "Name a Range..." So, for this example, you can select your category column and name it CategoryColumn. Same with ValueColumn.
Array formulas allow you to do IF statements and other functions on a whole range of data instead of just a single value.
This example checks if the value in the "category column" is "High". If it is, it puts the neighboring "value" into the MAX function, otherwise it puts a blank. This gives you the maximum of all the "High" values.
P.S. I don't think the img tag works on this site...can't see your image.
There are three options available.
My preferred option is to create a pivot table without a helper column.
Option 1: Use a pivot table
Create a pivot table of your data.
Set the row to the date field and group it by year.
Alternately a 'Year' helper column could be used by adding a column with this formula.
=YEAR(A2)
Set the data items value portion of the pivot table to be the MAX of your 'High' field
Option 2: Use the DMAX function
Add a helper column titled year with the formula
=YEAR(A2)
Then add a formula for each year
=DMAX(A1:C21,"High",F13:F14)
Option 3: Use an array formula
Enter an array formula for each year using the Ctrl-Shift-Enter keys.
{=MAX(IF(YEAR(A2:A21)=2008,B2:B21))}
Related
I have a Power Query table that updates on a regular basis. The table has columns named "Volume Third Party_some number". After the update, the number of the column with this name may increase or decrease. At the end of the table, there is a calculated column that has the formula to subtract from the last column with the name sum of the columns with the name written above.
In the power query editor, I couldn't find any formula which would help me to get the last column with the name, so instead, I'm trying to create a dynamic SUM function/sub procedure that would get the last column with the name "Volume Third Party_some number".
I have attached a screenshot
and from it, you can see there is a column "Volume Third Party_47" and column "Volume Third Party_48". After the update "Volume Third Party_48" was added but the SUM function is referring to the values from the column "Volume Third Party_47". So instead I need a function/sub procedure in VBA which would change the reference to the last column in the formula, in this case to the column "Volume Third Party_48" and also put a filter to a new reference column (it should remove 0 & blank values), while deleting it from another one.
Any ideas on how to make this VBA code?
This can be made possible using some change in excel formula.
If the name of you table is Table1 and the first column header of your table is firstColumn, then you need to replace [#[Volume_Third_Party_47]] in your formula with
OFFSET([#[firstColumn],,COUNTA(Table1[#Headers])-2)
But you entire formula should be something like this:
=IFERROR(
OFFSET([#Column1];;COUNTA(SAPCrosstab_UA[#Headers])-3)-
SUM(
OFFSET([#[Volume Third Party]];;;;
(COUNTA(SAPCrosstab_UA[#Headers])-1) -
MATCH("Volume Third Party",SAPCrosstab_UA[#Headers],0)
)
);
"")
I am trying to create a tunnel chart using data from Pivot table. However, I can't find a way to set a condition for one column ("Response Received Column). I want the table to count 5 people, and show 3 people responded. If I do the regular filter, I will only show 3 people on the "Name" column.
Power-pivot solution. can be replicated directly in excel too.
Adding data to model, create an additional column say positive response with calculation as
=IF(Table1[response_received]="Yes", 1,0)
Click pivot table in first menu tab, and get your desired view like this
Note that I have used sum instead of count here.
You can use array formulas - like this.
In the result cell for Name enter formula:
=SUM(IF(ISBLANK(B2:B9),0,1))
the result cell for Response Received enter formula:
=SUM(IF((E2:E9="YES"), 1, 0))
(adjust the row range numbers as you need to match the range of the data)
IMPORTANT!
After you enter the formula you MUST press: (CTRL+SHIFT+ENTER)
That activated the array formula. You can confirm that by selecting the formula cell
and you will see curly brackets around, like so:
{=SUM(IF((E2:E9="YES"), 1, 0))}
Try it.
Say I have one column called colors with 1000 cells populated with values. Some of the cells have the word blue in it. In another column I have unique identifiers that correspond with the colors column. For example Blue can have a value associated to it of 01, 02, 04, or 05. The word blue appears 20 times within my name column. What is one way I can find how many unique identifiers are associated with the word blue?
In the example listed above the answer should return 4.
The current method I am using to accomplish this is by using a pivot table. I filter out any value in the name column that doesnt include the word blue. Then I count all the unique identifiers that appear in my pivot table.
EDIT: Notice how blue appears 8 times, but it only has the values 1, 2, 3, and 4 associated with it. How can I create a function that finds out how many values are associated with blue?
One option:
In Excel versions that support Power Pivot, add the data to the data model, build a pivot table and use the "Distinct Count" as the aggregation of the values.
Without Power Pivot, build a regular pivot table with the value field (bad wording of the field, sorry) nested under the colors field, then use Countif on the color column of the pivot table.
Assuming your data is located at A1:B21 try this:
Enter the following headers at D1:F1
Enter these ArrayFormulas
FormulaArrays are entered pressing CTRL+SHIFT+ENTER simultaneously, you shall see { and } around the formula if entered correctly
In D2 - Returns an unique combined list of Colors & Values:
=IFERROR(
INDEX($A$2:$A$21&$B$2:$B$21,
MATCH(0,COUNTIF($D$1:$D1,$A$2:$A$21&$B$2:$B$21),0)*1),"")
In E2 - Returns an unique list of Colors:
=IFERROR(
INDEX($A$2:$A$21,
MATCH(0,COUNTIF($E$1:$E1,$A$2:$A$21),0)*1),"")
In F2 - Returns the count of combined Colors & Values for each Color:
=COUNTIF($D$2:$D$21,$E2&"*")
Then copy the ArrayFormulas in D2:F2 till last row of data (i.e. row 21)
Column D could be hidden if required...
In addition to the answer in the first comment, you can filter it with something like this (not tested):
= SUMPRODUCT( IFERROR(1 / COUNTIFS(A2:A21, "Blue", B2:B21, B2:B21), 0) )
I have a sheet setup that calculates totals. Easy enough if the data is already there but not if adding new data. So what I would like to be able to do is to not specify a specific end cell for the sum formula but let it update as more columns are added.
How can I do this with =SUM(m4:m?)
Suppose you need totals for data in M4:M10.
To make just open-ended range, you can make lower limit "too far": =SUM(M4:M100000).
Alternatively you can make it as =SUM(M:M) - SUM(M1:M3)
But this is not applicable when you need to have totals value just below the set of values. In this case you have 2 ways.
Using Excel embedded features
The formula will look like his: =SUM(M4:M10). If you insert a new row between M4 and M10 (for instance, select row 5, right-click, insert row), you formula will be automatically adjusted to =SUM(M4:M10).
The problem may happen if you want to insert a new value above the first row (select row 4, right-click, insert row) or below the last row (select row 11, right-click, insert row). In these cases totals formula will not be adjusted.
Possible workarounds:
For the "above first row" issue, I prefer to make some empty row above and hide it. In our case I would hide row 3 and make totals formula look like =SUM(M3:M10), so, when you insert a new row above the first row, in fact you insert a row to the middle of the table, and totals formula will be adjusted.
For the "below last row" - leave empty row below; but in this case you cannot hide it; just make it different color and make some remark like "new values shall be inserted ABOVE this line".
INDEX()
Interesting trick is using INDEX() function, which returns a reference to a cell in the array. For our case, the array can be the whole M row and, the index - row number.
For the "above first row" issue make totals formula like this =SUM(INDEX(M:M;4):M10). So, calculation will always start at row 4, even if some lines will be added/deleted.
"below last row". Suppose you have your "totals cell" in M13 and you want to have totals for all value between M4 and the "totals cell". The formula may look like =SUM(M4:INDEX(M:M;ROW(M13))) or, considering "above first row" case: =SUM(INDEX(M:M;4):INDEX(M:M;ROW(M13)))
Hope this helps
Sum(m4:m?) insinuates that you are looking to add more rows as opposed to adding column data.
If you want to auto sum a row data you can use something like:
=SUM(OFFSET(A1;0;0;COUNT(A:A);1))
However this assumes that the data is contiguous in each cell and also empties are not allowed for 0 because it gets the count wrong.
However: You could also define a table for the data range. If you add data to columns/rows that are in that data range, they will be included in the adjusted formula automatically - very nice indeed.
Select your data range, then Select Insert:Table. This will give your table a name like Table1.
Your sum function would now be adjusted to look something like:
=SUM(Table1)
Now, as you add to the range, the table resizes, and your function just works.
The beauty of using a table, is that if you add data to the row/column immediately after the table it resizes and includes that range. This is hard to do without a table. You can also change the format of the table, or make the format colours invisible but you're probably better off with some format to show the data area of the table to the user.
You can compute the last row containing a number using this formula:
=LOOKUP(2,1/ISNUMBER($J:$J),ROW($J:$J))
This formula would not have a problem if you had text or blanks in the range.
You could then define that formula as a Defined Name
and use the formula:
=SUM(OFFSET(J4,0,0,LastRow-3))
to Sum the range. Note the -3 at the end to compensate for the first cell being in row 4.
Another option would be to just set your range to a fixed range that you can guarantee will be larger than any range you might actually use:
=SUM(J4:J1000)
You can use a counta to find the max row number. Then pushing that into an indirect will give you the range you need.
=SUM(INDIRECT("A1:A" & COUNTA(A1:A1000000);TRUE))
Assumptions:
Data are on column A
Data start from first row
There are no blanks rows
I've created a table with multiple columns in Excel, and I'm trying to let it autocomplete some columns based on another one: There's an "Item name" column and a "Item type" one, and I want to make excel autofill the Item Type field on every row based on the entry in the Item name field on the same row, is there a way to make Excel handle this by itself based on previous entries?
EDIT: Example for clarity:
If I insert "Pizza" in Item Name and "Food" in Item type, when I enter "Pizza" again in another row, Excel auto-fills the same row "Item type" field with "Food"
Based on your edit you want the vlookup function.
VLOOKUP( value, table, index_number, [not_exact_match] )
If index_number is less than 1, the VLOOKUP function will return
VALUE!. If index_number is greater than the number of columns in table, the VLOOKUP function will return #REF!. If you specify FALSE
for the not_exact_match parameter and no exact match is found, then
the VLOOKUP function will return #N/A.
But first you'll need to make sure that these associations are already present. You need a table like this. Assume that 'object' is a1 and 'type' is b1:
Object Type
Pizza Food
Car Vehicle
Now for your table that you're entering the values, assume that 'name' is d1 and 'type' is e1:
Name Type
Pizza =vlookup($d2, $a$2:$b$99, 2, false)
Car =vlookup($d3, $a$2:$b$99, 2, false)
The '$' will prevent the relevant cells from changing if you use autofill to complete the column.
If this is a set list that is relatively short you can manually enter it into the autfill options.
Microsoft gives you all the various ways to do this.
https://support.office.microsoft.com/en-us/article/Fill-data-automatically-in-worksheet-cells-74e31bdd-d993-45da-aa82-35a236c5b5db?CorrelationId=99c7dec0-4c5c-4988-b148-6d3b7c4dd2e5&ui=en-US&rs=en-US&ad=US
Also, creating a pivot table may be what you want to do. Simply highlight your main table and go to the insert table and click pivot table. Move the headers into the appropriate box.
The last option may be your best bet if it involces a ton of values. lookup/match functions will give you a more robust formula that is more versatile.
If you can give a sample set of data and what you want it to look like I can give you the formula.