[2 days left] Whatâ€™s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
Solved

I need to update the following formula

Posted on 2014-03-11
Medium Priority
280 Views
I need to update the following formula:

=IF(AND(g10>J10,K10>g10),"test1",IF(g10>K10,"test2",""))

I neeed to update it to include: (LEFT(G10, LEN(G10)-4). I cant get the sytnax right and it keeps erroring out.

G10 has a space and (X) in the cell that I need to be able to remove and look just at the date.
0
Question by:wrt1mea
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 7
• 5
• 3
• +2

LVL 8

Expert Comment

ID: 39920742
will you post your sample WB?
0

LVL 13

Expert Comment

ID: 39920758
pls share some example data/sheet
0

LVL 26

Expert Comment

ID: 39920765
Not sure what you are looking for without the sample but it sounds like you maybe only want to read the first 4 characters of G10 or you want everthing after the first 4 characters?

left(g10,4) will get the first 4

RIGHT(g10, LEN(g10)-4) will get everything after the first 4
0

LVL 1

Author Comment

ID: 39920849
Here is a sample
Ex-Ech-3-11-14.xlsx
0

LVL 33

Expert Comment

ID: 39920873
@pony10us
=(LEFT(G10, LEN(G10)-4)

Will give everything but the last 4 characters.

Thanks
Rob H
0

LVL 1

Author Comment

ID: 39920879
Thats all I want, everything except the last 4 in G10....

Now if someone could put that in the formula, that would be great. I kept getting errors.
0

LVL 33

Accepted Solution

Rob Henson earned 2000 total points
ID: 39920897
Try this:

=IF(AND(LEFT(G10,LEN(G10)-4)*1>J10,K10>LEFT(G10,LEN(G10)-4)*1),"test1",IF(LEFT(G10,LEN(G10)-4)*1>K10,"test2",""))

I have included *1 to force excel to recognise it as a number; maybe thats why it was still giving errors.

Thanks
Rob H
0

LVL 33

Expert Comment

ID: 39920900
To get syntax right I typed the formula in a separate cell:

=LEFT(G10,LEN(G10)-4)*1

Then copied the text of the formula to the clipboard, press F2 and highlight the formula in the formula bar and Ctrl C.

Then selected T10 and U10 and did edit replace:

Find         G10
Replace   LEFT(G10,LEN(G10)-4)*1  (pasted in)

Click Replace All.

Thanks
Rob H
0

LVL 26

Expert Comment

ID: 39920936
Rob,

Wouldn't this work as well?

=IF(AND(LEFT(G10,LEN(G10)-4)>J10,(K10>G10)),"test1",IF(LEFT(G10,LEN(G10)-4)>K10,"test2",""))

At least it seems to work in my tests.

EDIT:

Actually,  I just tested it agains some lines that I think should have resulted in "test1" (line 14 for example) and it didn't so I guess my formula isn't quite correct.
0

LVL 1

Author Closing Comment

ID: 39920962
GREAT JOB!

THANKS TO EVERYONE FOR THE HELP!
0

LVL 33

Expert Comment

ID: 39921373
Pony - what locale are you using?

The sample data that came through was in mm/dd/yyyy format so I had to tweak it a little bit first.

The sample on row 10 had 6/30/2014 (E) so I manually changed to 30/6/2014 (E) to allow for UK date recognition.

Thanks
Rob
0

LVL 26

Expert Comment

ID: 39921585
Rob,

I am in US so no need to alter the format from the original.

I wanted to play around some more to try and see where it was failing.

Givens:

G10 = 6/30/14 (E)
H10 = 9/24/14
J10 = 4/12/14
K10 = 11/12/14

In Cell L10 I put:    =(LEFT(G10,LEN(G10)-4))   which returned     6/30/14

In Cell M10 I put:    =IF(L10>J10,"yes","no")     which returned       yes
(6/30/14>4/12/14)

In Cell N10 I put:    =IF(K10>L10,"yes","no")     which returned       no
(this returned incorrectly)

I changed Cell N10 to:    =IF(K10>L10,K10,L10)     which returned  6/30/14
(also incorrect)

The format of both K10 and L10 is date 3/14/14 so not sure why everything worked until the final test.
0

LVL 33

Expert Comment

ID: 39921903
Although the LEFT function returned what looks like a date, is it actually a date. Format it as comma or another number format and it should be 41820; if not then its not a true date.

Alternatively shrink the column so the value won't fit. A number will go to ### whereas text will either partly disappear or run onto the next cell.

I have replicated the little test above and the text value "6/30/14" returns Yes and No as per your results but replacing the 6/30/14 with (for my locale) 30/06/14 returns the correct answers.

Alternative to the *1 would be DATEVALUE(LEFT(G10,LEN(G10)-4)) which should give a date in your locale as it will recognise the format of 6/30/14 as being 30 June, that didn't work for UK locale.

Thanks
Rob
0

LVL 26

Expert Comment

ID: 39922030
Rob,

Thank you,  after playing around I found that the formula in L10

=(LEFT(G10,LEN(G10)-4))

does NOT return a date.  Not sure what it returns but not the date 6/3/14 even though the cell is formated for that date format.  I formated the cell as General and it still looked the same.

I changed it to:

=(LEFT(G10,LEN(G10)-4))*1

and it returned the date value (when changing the cell format to general it gave the number 41820

All other calculations work properly with the *1 in the proper places.
0

LVL 33

Expert Comment

ID: 39922122
The LEFT part of the formula purely pulls a string of text. Putting the *1 on thend tells Excel to try and do some maths with it. If it were ordinary text it would fail but its clever enough to recognise it as a date so does the necessary calcs and returns the date.

Thanks
Rob
0

LVL 26

Expert Comment

ID: 39923602
Thank you again Rob.  That's why I like EE.  Always something new to learn while helping others at the same time.  :)
0

LVL 33

Expert Comment

ID: 39923644
Every day is a school day!
0

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.
Suggested Courses
Course of the Month14 days, left to enroll