Excel: Sort cell base on specific text - excel

Let's say I have something like this.
I want to sort it to be something like;
is there a function to do this in excel? Like sorting the data base on the x?

You can do that, using a helper column. However, you seem to have two criteria in your question:
Count the amount of x characters. This, you can achieve using a CountIF().
Sort, according to the location of the x character (in case there is only one).
You can achieve the second, using the following system (imagine that, instead of x, there's the number 1):
=G1 * 2^4 + F1 * 2^3 + E1 * 2^2 + D1 * 2^1 + C1 * 2^0
This will create the following numbers for your cases:
8 : Some Text : 1
9 : Some Text : 2
1 : Some Text : 4
...
Combining both calculations gives you what you want.

Related

How to convert an "enumerate" to array

I am trying to calculate sum(a.*b) = a[1] * b[1] + a[2] * b[2]+.....
The array a with length n is present in the sheet. Values of b though are not present directly.
To get b, there is a column of data and n indexes. b[i] = data[indexs[i]]
One way to find sum(a.*b) is to first buffer the value of b using INDEX(data, indexes) and then SUM(a * b).
I want it to be done in one cell with no buffering. So I tried replacing b with the formula of b like SUM(a * INDEX(data, indexes)). But excel considers INDEX(data, indexes) to be iterable and gives me [SUM(a * b[1]), SUM(a * b[2]), ...]
How do I tell excel to take INDEX(data, indexes) as an array?
sample
In earlier versions of Excel (pre-O365), you have to use the following manoeuvre to deliver an array using Index as described here:
=SUMPRODUCT(D3:D4*INDEX(A2:A10,N(IF({1},B2:B3))))
The curly brackets around the 1 {1} are not strictly necessary, but I tend to leave them in to signal that I am using this trick.

Raising a number to the power of a range of numbers

The formula I would like to use looks something like this: SUMPRODUCT(x^(1:n),y^(n:1)). n=values in column A. 1:n is the exponents in forward progression from 1 to n in steps of 1. n:1 is the exponents in reverse progression from n to 1 in steps of 1. I would like the formula to be dynamic to fill in column B with the n values based on column A.
Try:
=SUMPRODUCT(5^ROW(1:100))
Or in Excel O365
=SUM(5^ROW(1:100))
As per #RonRosenfeld, a more sturdy solution could be =SUM(5^SEQUENCE(100)) in Excel 365.
EDIT: Based on OP's comments he could use (no O365):
=SUMPRODUCT(5^ROW(A1:INDEX(A:A,COUNTA(A:A))),7^LARGE(ROW(A1:INDEX(A:A,COUNTA(A:A))),ROW(A1:INDEX(A:A,COUNTA(A:A)))))
You can store the powers in a column and use the array formula:
SUM((A1:A100)^$B$1) where A column contains 5 in each cell and B column contains the range of powers you want to use. You can use an array formula in the different cell to get the answer.
Use the SERIESSUM function
The Excel SERIESSUM function returns the sum of a power series, based on the following power series expansion:
Power Series Equation
The syntax of the function is:
SERIESSUM( x, n, m, coefficients )
Where the function arguments are:
x - The input value to the power series.
n - The first power to which x is to be raised.
m - The step size that n is increased by, on each successive power of x.
coefficients - An array of coefficients that multiply each successive power of x.
The number of values in the supplied coefficients array defines the number of terms in the power series. This is illustrated in the following examples.
Example 1:
In the spreadsheet below, the Excel Seriessum function is used to calculate the power series:
5^1 + 5^2 + 5^3 + 5^4 + 5^5
formula: =SERIESSUM( 5, 1, 1, {1,1,1,1,1} )
output = 3905
Example 2:
1 * 2^1 + 2 * 2^3 + 3 * 2^5 + 4 * 2^7 + 5 * 2^9
formula: =SERIESSUM( 2, 1, 2, {1,2,3,4,5} )
output = 3186
I hope this is of help.
An Alternative Answer again. I think the correct for your case :-)
Using the SERIESSUM function allows the use of different coefficients therefore the reason for the use of the coefficients in an array. But because the coefficients are the same then this is simply a geometric progression.
The following formula will do that for you:
=n+n*(n)^(1)*(1-(n)^c)/(1-n)
where "n" is the number (5) and "c" is the number of the series (100)
This becomes:
=5+5*(5)^(1)*(1-(5)^100)/(1-5)
=SUMPRODUCT(5^ROW(A1:INDEX(A:A,COUNTA(A:A))),7^LARGE(ROW(A1:INDEX(A:A,COUNTA(A:A))),ROW(A1:INDEX(A:A,COUNTA(A:A)))))
This formula worked flawlessly!!!
Thank you #JvdV and everyone else for your efforts in helping me! GREATLY APPRECIATED!

what does E represent in microsoft Excel?

Excel has just output this trendline: y = 0.032x4 - 5608.x3 + 4E+08x2 - 1E+13x + 1E+17
How can I convert this equation into a useable form without the E's.
(how do you interpret these E's)
You can use the trendline from a graph in an equation, but, in addition to translating it correctly, you need to also format the trendline to show a maximum number of decimals (e.g 15), else your results will not be congruent with the graph.
Your formula would translate into something like:
y = 0.032*(x^4) - 5608*(x^3) + 4E+08*(x^2) + 1E+13*(x) + 1E+17
4E+08 will be interpreted by Excel as being 4*10^8 or 400,000,000. You don't have to do that yourself,
However, unless you have a very old version of Excel, where the LINEST function did not work properly, it is usually simpler to just use worksheet functions for that purpose.
For example, if this is a line graph where y is your range of y-values; your trendline is a 4th order polynomial, and your x-axis is just serial numbers 1..n, you could use:
=LINEST($A$4:$A$12,SEQUENCE(COUNT(y))^{1,2,3,4})
to return your sequence of m values.
And to return a point along the curve, you could use
=SUM(LINEST($A$4:$A$12,SEQUENCE(COUNT(y))^{1,2,3,4})*A4^{4,3,2,1,0})
where A4 represents a new_x value.
If you don't have the SEQUENCE function, there are a variety of other functions that can be used to generate a sequence of values; or you can just select your known_x's (which you would have to do anyway if they are not sequential {1..n})
The Scientific format displays a number in exponential notation,
replacing part of the number with E+n, in which E (exponent)
multiplies the preceding number by 10 to the nth power. For example, a
2-decimal scientific format displays 12345678901 as 1.23E+10, which is
1.23 times 10 to the 10th power.
Before
y = 0.032x4 - 5608.x3 + 4E+08x2 - 1E+13x + 1E+17
After
y = 0.032x4 - 5608.x3 + 4 x 10^8x * 2 - 1 * 10^13x + 1 * 10^17
Basically really large numbers,4 x 10^8x*2=400000000x*2, 1 x 10^13x=10000000000000x, 1E+17=100000000000000000

Matching, splitting, converting and summing string in Excel / Numbers

I'm trying to do a match-and-calculate formula in Excel (or in Numbers for Mac, is the same for me: I try them both as they seem equal, also function names are equal!).
This is what I have:
| 1 | 2 | 3 |
|-----------+-----------+-----------|
| Category |other stuff| duration |
|-----------+-----------+-----------|
| A + .... ... + 00:01:23 |
|-----------+-----------+-----------|
| A + .... ... + 00:30:19 |
|-----------+-----------+-----------|
| B + ......... + ......... |
|-----------+-----------+-----------|
| A + .... ... + 00:22:12 |
... ... ....
So, in column 3 I have a duration in time in this format "hh:mm:ss" and in column 1 are stored all of my categories.
I want to search for all rows in my table that are matching with the category "A" in column 1 and take the relative column 3, splitting the string and converting chars to numbers (in particular I'm interested in converting them to secs, so hh*3600+mm*60+ss) and finally sum up all these values. Is it possible?
I'm new with Excel and Numbers, but I'm pretty familiar with coding in programming languages generally: this is what I'd do in programming:
global_secs=0;
for(row r=top to end){
if(r.get_column(1).content_equals("A")){
cell c=r.get_column(3);
string=split(c.get_content(),":")
global_secs+=int(string[1])*3600+int(string[2])*60+int(string[3])
}
}
Is there a way to achieve this in Excel sheet (or Numbers)?
I'd like to do all of this in one, or more, formula only in Excel or Numbers.
One more thing: I do not want to change cells format because this should be an automatic process without human interaction, so unless there is a function to change a range of cells format dynamically I prefer not to do that (I know I can make "duration" as format and sum up without converting to integer, but originally my data is in hh:mm:ss format)
Thanks so much!
The formula you are looking for is
=SUMIF(A2:A5,"A",C2:C5)
The easiest way to get the result in seconds would have been to format the cell as [ss] in Custom category. But as you don't want to do formatting , the other way could be
=HOUR(result) * 3600 + MINUTE(result) * 60 + SECOND(result)
So formula becomes
=HOUR(SUMIF(A2:A5,"A",C2:C5)) * 3600 + MINUTE(SUMIF(A2:A5,"A",C2:C5)) * 60 + SECOND(SUMIF(A2:A5,"A",C2:C5))
See image for referecne
Looks like a matrix formula
=SUM(N($A$2:$A$8="A")*$B$2:$B$8)
where column A contains the category and column C the duration. Note you need to press ctrl shift enter to make it work.
To convert the result to seconds, an alternative approach to #Mrig' solution would be to format the result and convert it back to a number, i.e.
=VALUE(TEXT(SUM(N($A$2:$A$8="A")*$B$2:$B$8),"[ss]"))

What is the easiest way of composing this polynomial expressions in Excel?

This is trivial in programming languages, but when I need to do something quick & dirty and to see whether I got the coefficients right, I usually go for Excel.
So, what have I got,
c1(i) c2(i) c3(i)
0,321323232 1 0
0,32132122 0 2
0,321214324 1 2
...
..
.
The polynomial expression is
KT = SUM( AEA0 * c1(i) + J * c2(i) + PD * c3(i) )
i=1,37
One approach would be to make columns with AEA0, J, PD (btw, these are constants) and then multiply & sum them with the coefficient columns. I don't like this one because it adds a lot of extra stuff, and it messes up my copy pasting later (when I copy paste the coefficients to a text file).
Second approach would be to manually form an expression clicking all the cells one by one,
KT = AEA0 cell * A1 + J * B1 + PD * C1 + AEA0 * A2 + J * B2 + PD * C2 + ...
you get the point. Is there a way to improve this approach in some way so it takes a range of A1 to A37?
Is there some better approach to forming this kind of expressions?
Put the value for AEA0 in Z1. Put the value for J in Z2. put the value for PD in Z3.
Then you can use:
=SUM(A1:A37)*Z1+SUM(B1:B37)*Z2+SUM(C1:C37)*Z3

Resources