I'm looking for some tips to transform a result I have in a cell from text to long.
In Cell A1 I have : "8 days 5 hours 10 minutes"
In cell B1 I have : "8*86400+5*3600+10*60" which I have with some "substitue"'s function
here is the function : ""=SUBSTITUE(SUBSTITUE(SUBSTITUE(SUBSTITUE(A1;" days";"*86400");" hours";"*3600");" minutes";"*60");" ";"+")""
In cell C1 i would like the result
My problem is I need this "8*86400+5*3600+10*60" to be "709800", and I can't find a way to reach it.
I thought it was about formating my cells but I tried everything and it didn't worked.
I can bet I tried all excel functions...
I'm stuck actually and looking for some good ideas.
Thank you for your help or advices !
File_picture
Here is a formula to perform the calculation from your string. It relies on the format as you have above, with a single space between each item in the string.
=SUMPRODUCT(--TRIM(MID(SUBSTITUTE(A1," ",REPT(" ",99)),{1,198,396},99)),{86400,3600,60})
The formula creates an array of the relevant values, and then applies the appropriate multiplier.
If there might be more than one space between each segment, then use:
=SUMPRODUCT(--TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",99)),{1,198,396},99)),{86400,3600,60})
Related
My question is, I want to find a specific characters "V-", "C-", or "To", from the value in the cell B2,
The logic is: if either of these characters are found in the cell B2, the excel should take value from D2, and put into new column say E
Here is my if formula:
=IF(MID(B2,FIND("V-",B2),2)="V-",D2,
IF(MID(B2,FIND("C-",B2),2)="C-",D2,
IF(MID(B2,FIND("To",B2),2)="To",D2," ")))
This formula is working for only first occurrence "V-" in this case , the rest of the values it displays "#VALUE!". Can I get any help please.
And return a blank otherwise?
=IF(COUNT(FIND({"V-";"C-";"To"},B2)),D2,"")
Just to spell out what's happening, if it Find fails to find "V-", it immediately returns a #VALUE! error and the formula doesn't proceed any further.
You could fix it like this while preserving your logic
=IF(ISNUMBER(FIND("V-",B2)),D2,
IF(ISNUMBER(FIND("C-",B2)),D2,
IF(ISNUMBER(FIND("To",B2)),D2," ")))
but as you can see from the other answers there are much shorter ways of doing it.
Try this way:
`=IFERROR(FIND("V-",B2),IFERROR(FIND("C-",B2),IFERROR(FIND("To-",B2)," ")))`
returning a positive number when found or " " when no match.
(I could not test it because I use a localised version of Excel but the logic is fine)
This function formula looks in the specified filepath in cell A2 and returns the filename based on the file extension in cell B2:
Formula in Cell A4 : =IFERROR(INDEX(GetFileNamesbyExt($A$2,$B$2),ROW()-2),"")
Result Cell A4 : Servicing Balance Allocation Report 1-13-2020.xlsx
The problem though is, I need to be able to extract the number 13 in the above Result so I can do math with it. Problem I run into is that since the result is a formula result, I can't seem to extract the day portion.
I don't mind if someone has a VBA solution, whatever works.
The goal is to be able to get the number of days difference between the two most recent files based on the date in the file string.
For example:
Difference between:
Servicing Balance Allocation Report 1-13-2020.xlsx
Servicing Balance Allocation Report 1-17-2020.xlsx
= 4
Consider:
=LEFT(MID(A4,FIND("-",A4)+1,999),FIND("-",MID(A4,FIND("-",A4)+1,999))-1)
basically getting the text between the dashes.
NOTE:
It is easier to see in two cells. Say in D1 put:
=MID(A4,FIND("-",A4)+1,999)
and in E1 put:
=LEFT(D1,FIND("-",D1)-1)
To get the day use:
=DAY(--TRIM(LEFT(MID(A4,SEARCH("??-*-????.",A4),999),FIND(".",MID(A4,SEARCH("??-*-????.",A4),999))-1)))
to get the days between we can drop the DAY() and just subtract the dates:
=TRIM(LEFT(MID(A5,SEARCH("??-*-????.",A5),999),FIND(".",MID(A5,SEARCH("??-*-????.",A5),999))-1))-TRIM(LEFT(MID(A4,SEARCH("??-*-????.",A4),999),FIND(".",MID(A4,SEARCH("??-*-????.",A4),999))-1))
I'm using counting invoice numbers (text) in a table's column, but the Excel formula seems to be confusing some values.
I copied small sample of these - please refer to below:
The formulas are as follow:
=COUNTIFS(A1:A19,A1)
=COUNTIF(A1:A19,A1)
As you can see these invoice numbers differ and the results of these functions suggest as if all were the same.
I googled it for 1 hour but I didn't find such as issue as mine.
If anybody had any clue why could this behave in such way I'll be super grateful!
Rob
Each time you copy down this formula it will add 1 row to each. For example the second row of datas formula will be =COUNTIFS(A2:A20,A2). To lock these cells in the formula use $
Your formula should be =COUNTIFS(A$1:A$19,A1)
I've solved this myself:
ROOTCAUSE
Excel tried to be helpful and read these invoice numbers as actual numbers (despite these being defined already in Power Query as text)
Then, Excel fooled me and despite showing that it works on it as a string (I was evaluating the formula) it worked on it as number
Above means that it transformed exemplary "00100001010000018525" to 1.00001E+17, which cut down this to "100001010000018000" - that's the moment Excel stopped fooling around and showed that value in the formula bar.
I think I don't need to tell why countif perceived all these values as equal.
SOLUTION
I simply appended one letter after each invoice number to get e.g. "00100001010000018525a" what forces Excel to quit its gimmicks and games.
Case closed.
I suspect this is a bug in COUNTIF, or maybe by design.
However, to workaround this in the formula, without having to change your data, try adding a wild-card character:
=COUNTIF(A1:A19,"*"&A1)
I am trying to write a formula that checks the status and name to be ongoing and joe blogs (in this example), and once finding a match, will identify the oldest date of a ticket raised.
My formula currently includes:
=MIN(IF('Sheet2'!AA:AA="ONGOING",IF('Sheet2'!Q:Q="Joe Bloggs",'Sheet2'!B18:B49)))
I also tried:
=IF((AND(sheet2!$AA:$AA="ongoing", 'Sheet2'!$Q:$Q="Joe Bloggs")), MIN('Sheet2'!B18:B49),"No")
In Column B contains dates. Q contains names, AA contains the status.
At the moment when this runs I get the result '00/01/1990'.
I have done some checks to find the error, and appears to be around the targets name, as when the second formula is tried, the output is "no". The name is definitely in the Q column, and I have completed other formulas including countifs which have worked perfectly fine.
I have done a lot of searching to find nested ifs and min statements to have no joy , would be grateful of any advice / tips. It may be a simple error to some.
Try entering this as an array formula:
=MIN(IF(sheet2!AA:AA="ongoing",IF(sheet2!q:q="Joe Bloggs",sheet2!B:B)))
FYI I found the solution here.
You will have to apply a date format to the result.
Your first formula works well on my data (as below). If I close the formula with ENTER only, I get the result '37128' and if I close the formula with CTRL+SHIFT+ENTER I get the expected result, '25/08/2001'.
Edit: As #FocusWiz said in the comments, the only major difference (other than different column names) between my formula and yours is the the last range in your formula (B18:B49) is a different sized range to the other two, which are referring to full columns.
*This could be solved either by using the same row range for all three column references (AA18:AA49, Q18:Q49, B18:B49) or referencing the full column range for all three ranges (AA:AA,Q:Q,B:B).
This is your formula I'm talking about:
=MIN(IF('Sheet2'!AA:AA="ONGOING",IF('Sheet2'!Q:Q="Joe Bloggs",'Sheet2'!B18:B49)))
And this is the formula in my workbook F7:
=MIN(IF(B:B="ONGOING",IF(A:A="Joe Bloggs",C:C)))
As you can see in the formula editor, squiggly brackets '{}' show around the formula when it has been closed as an array formula.
If that doesn't work for you, please post some sample data with datatypes so we can help figure out what is causing the lookup value to miss the data.
While I like the technique offered by Patrick (I have frequently forgotten an "else" portion of a formula and gotten "false" as a value in a cell but never thought of a use for that...thank you!), I think this question highlights an issue we all can have with array formulas. As girlvsdata indicates, your original formula:
=MIN(IF(Sheet2!AA:AA="ONGOING",IF(Sheet2!Q:Q="Joe Bloggs",Sheet2!B:B)))
(modified above to be more generic for column B) will also work when entered as an array formula.
What likely happened is that somehow the formula got edited and was not re-entered as an array formula.
While I do not dislike array formulas, I do try to avoid them because I have fat fingers and will frequently mess them up by accidentally hitting the wrong key as I am modifying other cells.
Here is an alternative without using an array formula:
=INDEX(LARGE((Sheet2!Q:Q&Sheet2!AA:AA="Joe bloggs"&"ongoing")*(Sheet2!B:B),COUNTIFS(Sheet2!Q:Q,"Joe Bloggs",Sheet2!AA:AA,"ongoing")),1)
What it does is basically create a candidate date value for every row that has "joe bloggs" and "ongoing" which is equal to the date in column B for all such rows. All other rows get a zero candidate date value. The LARGE function takes the smallest nonzero date by counting the n valid candidates with the COUNTIFS function and taking the nth largest such candidate.
I´ve spent a lot of time with a formula in Excel and I´m still blocked. I hope you can help me.
I have a table in Excel with several values as shown in this
screenshot.
What I´m trying to extract is the number of Fruits sold in a specific month. That is, how many lemons were sold in January 2016, for example. This is the formula I´m using:
=SUMPRODUCT((B3:B38=E4)*(MONTH($A$3:$A$150)=12)*(YEAR($A$3:$A$150)=2015);$C$3:$C$150)
But the result is #N/A as seen in the screenshot.
What Am I doing wrong? Any help, please?
Thanks a lot in advance!
You can use arrays in excel to get this answer
{SUM(IF(MONTH(F$3&"1")=MONTH($A$3:$A$150),IF($E4=$B$3:$B$150,$C$3:$C$150,0),0))}
You can use this Sumproduct formula which uses array logic:
SUMPRODUCT((MONTH($A$3:$A$38)=MONTH(TEXT(G$2,"MMM")&1))*($C$3:$C$38=$F4)*
($D$3:$D$38))
Sumproduct Demo
Part of your problem is your ranges are not equal in length. B3:B38 has to be the same number of rows as $A$3:$A$150 and C3:C150. When rows are not equal things blow up on you.
=SUMPRODUCT(($B$3:$B$150=$E4)*(MONTH($A$3:$A$150)=12)*(YEAR($A$3:$A$150)=2015);$C$3:$C$150)
if you change your header row to be actual excel date format, and then change the cell display format to just show the month (as suggested by csanjose), then you can adjust your sumproduct formula as follows and copy to all cells in your table.
=SUMPRODUCT(($B$3:$B$38=$E4)*(MONTH($A$3:$A$150)=Month(F$3))*(YEAR($A$3:$A$150)=Year(F$3));$C$3:$C$150)
Fill your month-row with the last day of each month, then apply date format to show only month name.
The formula you should use is, for example, in g8:
=SUMIFS($C:$C;$B:$B;$E8;$A:$A;"<="&G$3;$A:$A;">"&F$3)
First column "F" doesn't have a column on the left to compare, so you can put a date in E3 or change a bit the formula (example of F8):
=SUMIFS($C:$C;$B:$B;$E8;$A:$A;"<="&F$3;$A:$A;">2015/12/31")
Take a look at the result
If you don't want to use a pivot table, you can use this formula to get what you need:
=SUMPRODUCT(($B$3:$B$150=$E3)*(MONTH($A$3:$A$150)=1)*(YEAR($A$3:$A$150)=2015)*$C$3:$C$150)
Then drag-fill the cell to copy it to every month column (just make sure you change the month number in the formula (and year if you're doing that too)), and then drag-fill down the columns.
That should work pretty food good :)
Good Luck!