I am trying to create a formula in Excel that returns the highest decimal value for every integer in a list.
For example, my sheet may have the values [10, 10.1,10.4, 11.3] and I need it to return both 10.4 and 11.3 since 10.4 is larger than 10 and 10.1, and 11.3 is the largest decimal value for 11.
I need this so that a pivot table can filter out the values as IDs and only return the highest value, but I can't get anything working to the point that providing my existing 'code' wouldn't help whatsoever.
Thanks for the help
If your list is sorted, you could use the Advanced Filter to generate a list of the highest decimal value for each integer.
Given:
Criteria Formulas:
A2: =A6<>INT(A6)
B2: =OFFSET(A6,1,0)=INT(OFFSET(A6,1,0))
Criteria Dialog
Note that you can choose to have the results copied elsewhere
Results
Solve as follows:
value bracket decimal
10 =int(a2) =a2-b2
10.4 =int(a3) =a3-b3
10.1 =int(a4) =a4-b4
11 =int(a5) =a5-b5
11.3 =int(a6) =a6-b6
or values:
value bracket decimal
10 10 0
10.4 10 0.4
10.1 10 0.1
11 11 0
11.3 11 0.3
Now pivot by:
bracket (columns/rows)
and in the value section add the "original value", aggregate by "max".
Pivot table and then group.
pivot table
change PivotTable Fields values to Max of values
group
result
Related
I'm trying to use XLOOKUP to find a value based on user inputs.
The table looks like this:
Type Start End 33 36 42 48
---------------------------------------
4002 1 7 1.17 1.34 1.5 1.84
4002 8 12 1.84 1.67 2.1 3.45
User selects type, number (can be between start and end), and 33-48
I can nest an XLOOKUP to specify the 3 criteria
=XLOOKUP(*type* & *number* , *typeRange* & *numberRange* ,XLOOKUP(*33-48* , *33-48Range* , *ResultRange* ))
And I can find if a value is between the columns
=IF(AND(*number*>=*Start*,*number*<=*End*),TRUE,FALSE)
Can I combine the two? The data is redundant for numbers 1-7, and I would like to keep the table small.
You sort-of can combine them. I have added a couple of extra rows to the table to see what would happen if you had different Type values as well as number values. The problem then is that if you used approximate match and put in a number like thirteen which is out of range, you might end up getting the next row of the table which would be incorrect. One way round it would be to use the options in Xlookup to search for next-smaller-item in the Start column and next-larger-item in the End column and see if the results match:
=IF(XLOOKUP(I2&TEXT(J2,"00"),A2:A7&TEXT(B2:B7,"00"),XLOOKUP(K2,D1:G1,D2:G7),,-1)=XLOOKUP(I2&TEXT(J2,"00"),A2:A7&TEXT(C2:C7,"00"),
XLOOKUP(K2,D1:G1,D2:G7),,1),XLOOKUP(I2&TEXT(J2,"00"),A2:A7&TEXT(C2:C7,"00"),XLOOKUP(K2,D1:G1,D2:G7),,1),"Error")
If you have some checks in place which make it impossible for number to be out of range, then you can simplify the formula:
=XLOOKUP(I2&TEXT(J2,"00"),A2:A7&TEXT(B2:B7,"00"),XLOOKUP(K2,D1:G1,D2:G7),,-1)
or
=XLOOKUP(I2&TEXT(J2,"00"),A2:A7&TEXT(C2:C7,"00"),XLOOKUP(K2,D1:G1,D2:G7),,1)
How do I sum the amount of demand I have for each date, when there are multiple entries for each date., e.g.
Sheet 1:
A B
Date Demand
13/7/21 5
13/7/21 4
13/7/21 2
15/7/21 6
15/7/21 3
16/7/21 2
16/7/21 4
So I'm trying to get a summary as follows:
Sheet 2:
A B
13/7/21 11
14/7/21 0
15/7/21 9
16/7/21 6
17/7/21 0
I've tried =SUMPRODUCT(--('Sheet 1'!$A$2:$A$240='Sheet 2'!A2),'Sheet 1'!$B$1:$B$240)
I'm not wanting to do a pivot table, as the pivot table does not give me the zero values for dates where there is no data (unless there is a way to show this in a pivot)
You can use SUMIFS() like
=SUMIFS(Sheet1!B:B,Sheet1!A:A,A1)
You can also use SUMPRODUCT() in this way.
=SUMPRODUCT((Sheet1!$B$2:$B$8)*(Sheet1!$A$2:$A$8=A1))
Put together quickly to start you off:
Edit to give text version of the solution to the OP's problem:
=SUMIFS(B6:B12,A6:A12,"="&G12)
Then you can do between by setting lower and upper criteria in the sumifs().
I am attempting to create an Excel formula to return an array of values based on logic.
I am aware of Excel functions like SUMIFS that accept parameters for range and condition, but instead of returning a sum of range, I want to return a (cell overflow) array of values based on condition.
This answer helped, but I do not want the return array to be sorted. I need the array indexes to be the same as if they were filtered.
Example cells:
Name Type Shares Price
STA Buy 12 5.7
STA Buy 15 3.8
STA Buy 100 5.4
STA Sell -50 5.8
GA Buy 55 3.55
Current formula:
# works but sorted least to greatest, want to return non sorted
=SMALL(IF((NameRange="STA")*(TypeRange="Buy"),PriceRange),ROW(INDIRECT("1:"&COUNTIFS(NameRange,"STA", TypeRange,"Buy"))))
This returns:
3.80
5.40
5.70
I am attempting to return non-sorted, as in original display order of matches:
5.7
3.8
5.4
If you have access to Microsoft 365 you can use FILTER to produce your output:
=FILTER(D2:D6,(A2:A6=H3)*(B2:B6=H4))
You could also return your values in a comma seperate string by nesting the above formula in TEXTJOIN(", ", TRUE, [FORMULA ABOVE]) which would yield 5.7, 3.8, 5.4
I have 10,000+ row of values which need to be indexed with a numerical value which increases by 1 every 56 rows - for example:
Rows Index Value
1-56 1
57-112 2
113-168 3
169-224 4
Any ideas?
Thanks! :-)
If your data starts in Row #2 like your example implies, then try this formula in Row #2 the column where you want your "index number":
=INT((ROW()-1)/56)+1
The 1 in the middle is "how many rows to skip at the top", and the 56 is obviously the size of each group.
More Information:
Office Support : ROW Function (Excel)
Office Support : INT Function (Excel)
I have big amount of data (60k rows) in Excel that is similar to this:
Temperature Humidity Date
20.1 68 22-dec-14
20.3 67 22-dec-14
20.4 65 22-dec-14
20.0 64 23-dec-14
20.5 64 23-dec-14
20.9 65 24-dec-14
21.4 64 24-dec-14
23.4 64 25-dec-14
23.8 65 25-dec-14
23.9 64 25-dec-14
18.4 64 25-dec-14
I created new columns outside this table that contains the individual dates and I want to extract the MAX, MIN and possibly the AVERAGE of that date
DATE MIN MAX AVG
22/Dez/14
23/Dez/14
24/Dez/14
25/Dez/14
I tried but I can't seem to find a way for Excel to work for me. Could you help me?
I suggest you try a PivotTable:
Suppose column A contains the dates, and column B the values. I've allowed 6 rows in each; extend as necessary.
Consider a sample date in $D$1. The formulas you need are:
MIN: =MIN(IF(D1=A1:A6,B1:B6,MAX(B1:B6))). (You need to enter this as an array formula).
MAX: =MAX(IF(D1=A1:A6,B1:B6,MIN(B1:B6))). (You need to enter this as an array formula).
Use AVERAGEIF out of the box.
Remember that you need to press Ctrl + Shift + Return to enter an array formula. Then it's a simple case of copying that formula downwards.
They return the minimum or maximum value of the entire sample if a given date is not present in the set, which might not be desirable. You could adjust this behaviour with a containing IF.
You can take care of the pseudo-MIN/MAX with the AGGREGATE¹ function using the 14 (LARGE) and 15 (SMALL) sub-functions together with the 6 (ignore errors) option and the AVERAGEIF function can take care of the rest.
The standard formulas in F2:H2 are,
=AGGREGATE(15, 6, ($A$2:$A$60000)/($C$2:$C$60000=$E2), 1)
=AGGREGATE(14, 6, ($A$2:$A$60000)/($C$2:$C$60000=$E2), 1)
=AVERAGEIF($C$2:$C$60000, $E2, $A$2:$A$60000)
Fill down as necessary. An advantage of this method is that you can get the second, third, etc smallest or largest simply by raising the 1 (k ordinal) number at the right end of the AGGREGATE formula.
¹ The AGGREGATE function was introduced with Excel 2010. It is not available in earlier versions.