473,394 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Excel formula

47
Hello all.

If someone could please help me with the following formula.
I'm using MS Excel, Office 2003.

Formula is in Q23:

If M22 is smaller than S22, than have value of D23, otherwise have empty cell.

(This part now I know how to make.)

However, if M22 is smaller than S22, than have value of D23 and keep on doing this (down Q column) for as long as it takes for value in M to become bigger than value in L, despite M may become bigger than S. Once value in M becomes bigger than value in L (after M dropping below S first) have empty cells until condition is met again.

All in all – I am trying to identify (in Q column) what are the values in D column when value (in M) drops more than X standard deviations (which is in S) from the mean until it recovers above mean (which is in L).

Help would be truly appreciated.

Thank you.
Feb 1 '10 #1
11 2591
NeoPa
32,556 Expert Mod 16PB
Let's start with the basics:
A cell can only be empty if it has no formula in it. A formula can return a 0 or an empty string, but empty cells cannot result from a formula.

That said, I will assume you are after cells which look empty. If not, then let me know & I'll go through a technique I use for producing empty cells dependent on a formula.

=IF($M22<$S22,$D23,"")

At this stage I have to stop as your explanation of the problem starts to tie itself in knots. What you say cannot be right as it contradicts itself. Please try to define what you want in a consistent manner. If you want to explain this on a per line basis, that's fine. If so, then do it all that way.

I wouldn't be surprised if this is why you haven't managed to solve it yourself. A solution always starts with a clearly defined & understood problem.
Feb 1 '10 #2
bcr123
47
Hello NeoPa,

Thank you for your time.

=IF($M22<$S22,$D23,"") is part that I knew how to sort out and empty string is what I had in mind, but lacked proper terminology.

When it comes to full explanation:

I am trying to present in Q column what are the values in D column when value (in M) drops more than X standard deviations (which is defined in S) from the mean until it recovers above mean (which is in L).

So, if we are for first 99 cells below mean (L) that is not of importance to me, but if we drop (M) in cell 100 below S, I would like to have presented in column Q (from cell 101, as drop happened in cell 100) values of column D, for as long as it takes M to turn bigger than S and L.

Basically, I am trying to say to Excel:

Give in column Q corresponding values of column D only during periods when M is smaller than S or L, but only after M falls below S (for at least 1 event). When M recovers above L, wait for it to fall below S again and than again give me in column Q corresponding values of column D until M recovers above L again.


Thank you, once again, for your time and consideration.
Feb 1 '10 #3
NeoPa
32,556 Expert Mod 16PB
@bcr123
As I cannot imagine M ever being smaller than S or L (I assume you mean smaller than either of S or L) at any point before it falls below S, I find this question still hard to pinpoint. From your description elsewhere, I'm not sure what I can assume about your data. You seem to be implying that column L is a repetition of the same (mean) value in each row, yet as you don't state that, I can only assume it couldn't be the case. After all, who would miss out such an important part of the question if it were the case. I'm still fundamentally unsure of what you're trying to do.

I expect it's in there somewhere, but unfortunately as it's still a little self-contradictory, I cannot tell which bits I can rely on and which are the red-herrings. I do appreciate how hard people can find this, so I'll have a stab at an answer anyway. Just bear in mind that without a proper understanding of the issue the answer may be entirely inappropriate.
Expand|Select|Wrap|Line Numbers
  1. =IF(AND($M22<$S22,$M22<$L22),$D23,"")
Feb 1 '10 #4
bcr123
47
Thank you for the effort NeoPa and I am sorry for the confusion.

Red line = S column
Black line = L column
Blue line = M column

I am sorry for posting graph, but as I am extremely visual I’ve decided to try to explain myself using a bit of graphics.

I would like to say to Excel to do this in every cell of Q column:

If Blue line (M) dropped (for first time ever) below Red line (S) return value that is D column.
If it has not dropped below – return empty string.

After Blue Line drops (for first time ever) below Red line (S) keep on giving corresponding values from D column (i.e. D123 value to be displayed in Q123, etc.) for as long as it takes for Blue line (M) to get above Black Line (L).

After this event (M>L) keep on returning empty strings for as long it takes to get to regime M<S again (second time ever) and then keep on giving corresponding values from D column (i.e. D123 value to be displayed in Q123, etc.) for as long as it takes for Blue line (M) to get above Black Line (L).

“First time ever” is marked with yellow dot on graph, while “Second time ever” is marked with purple dot.

Your time is truly appreciated.

Thank you.
Attached Images
File Type: jpg forum - Copy.jpg (16.8 KB, 216 views)
Feb 1 '10 #5
bcr123
47
Hello.

Just a follow-up, as result of some help from another forum:

I’ve introduced another column U with:

=IF(M30<S30,1,IF(M30>L30,0,U29))

with Q in same row

=IF(U30=0,"",D30)

Thank you NeoPa for your time and kind consideration.
Feb 1 '10 #6
NeoPa
32,556 Expert Mod 16PB
Column U can be helpful, but only in as far as it simplifies the formula in Q.

Can I first get you to confirm that referring to cells in both rows 22 & 23 in your 1st post was simply a typo. I cannot match this logic with wat you've explained most recently, and this makes for a shifting sand scenario that's hard to work with.

Visual examples are all well and good, but they have the disadvantage of displaying an example rather than the fundamental logic. Certainly the explanation is further forward, but I still see parts of the text explaining that only the first time it crosses a line is important, as well as other parts which imply that this needs to be repeated when the line is crossed again. These cannot both be true. Put another way, I can do either scenario, but not both.

Your example data has M going below S before it goes above L. What if the data doesn't come in this order? A formula would need to handle the data definitively, not as a series of examples.

It can be helpful to explain both from an overall perspective as well as from a line-by-line one. Unfortunately, in this case it is so critical that they match exactly. Unfortunately they don't in this case. It may be only a minor oversight from your end, but I have no way of knowing which bits to rely on in these circumstances.

Lastly, this is doable I suspect. Nothing I've seen is too much for Excel to handle, though depending on exactly what is required the formula may involve some conditional sums of the preceeding data in Q (which can be a little fiddly). Nothing beyond us though. It really is just a matter of getting the specification clarified (and progress has truly been made on that score. It's just a little rough edges that still need trimming) and we should be good to go. Please don't think I'm just trying to put off the effort of resolving this for you. It's actually a lot more time and effort to explain all this clearly, than just doing the formula when it's ready.
Feb 2 '10 #7
bcr123
47
Hello NeoPa.

If, as an example, M drops below S in row 100, I will need Q101 = D101, as from that cell I have new regime, because cell 100 was the one that triggered the event of new regime and observation starts from row 101. Hence, I shall have in U101 the following:

=IF(M100<S100,1,IF(M100>L100,0,U100))

and in Q101:

=IF(U101=0,"",D101)

If M100 is less than S100 than return 1
elseif
If M100 is greater than L100 return 0
else
return value from U100

(My first set of data for U column is in row 23, while U22 has manually entered 0 as value. This means that 0 is going to be returned until, in this example, row 101 where I am going to get 1 that is going to be returned for as long as M doesn’t become greater than L again and that’s when 0 is going to be returned again, until M doesn’t become less than S again.)

This, as it is, is working well with my problem and I’ve visually inspected graph, just to make sure proper periods are recorded and all is well.

As I was working with some friends on another forum on this, I’ve learned that this is Nested IF function and all of this would be much easier if I had knowledge of Nested IF.

I am really sorry if the way I communicate is not clear – From the very beginning I was trying to explain that I was interested to display in column Q corresponding values from column D only during period(s) during which M has dropped below S until it recovered above L. All other events would trigger empty string.

I appreciate your time and seniority on this forum, especially because you are very helpful to numerous users of bytes.com (including myself).

Thank you NeoPa.
Feb 2 '10 #8
NeoPa
32,556 Expert Mod 16PB
I appreciate that you have always made every effort to be as clear as you can. The problem is that describing logic is actually very difficult to do well (regardless of appearances) and very few can describe your situation very clearly without falling over the issues you have.

I have another problem atm. I get blocked out from being able to download pages from Bytes for long periods for some reason. That is why (as well as general busy-ness elsewhere) I haven't replied as quickly as otherwise I might have. Never mind. I'm about to leave for another office, so I cannot get into this too deeply just now, but let me see if I can help with the nested IF idea :
  1. Excel formulas are just that. The IF() function returns one of two values depending on the result of the first parameter.
  2. Each of those values may be a simple value, or it could itself be the result of a function call.
  3. Expand|Select|Wrap|Line Numbers
    1. =IF(A>2, IF(A<5, B, C), D)
    In this example the result for the values of A would be :
    1. A=1 D
    2. A=2 D
    3. A=3 B
    4. A=4 B
    5. A=5 C
  4. Another very useful pair of functions are AND() and OR().
    Expand|Select|Wrap|Line Numbers
    1. =IF(AND(M23<S23,M23<L23),"",D23)
    If M23 is less than the smaller of S23 & L23 then empty string, otherwise D23.
When I get a chance later I'll see if I can put all you say together to make a consistent set of logic and suggest a formula. BTW Is what you have already with the extra column working for you? You seem to feel it is, yet it doesn't match my understanding of what you're saying. Knowing this would help me put the pieces together correctly.
Feb 2 '10 #9
bcr123
47
Thank you for your time and kind consideration.

What I have is working well – double and triple-checked (manually) on graph and in Excel’s sheet (row-by-row checked) and I am exactly getting in column Q corresponding values from column D, during regime when M falls below S until it recovers above L, as that is only regime that is of interest to me in this exercise, while for all other regimes I am getting empty string.

Thank you, once again, for your time.
Feb 2 '10 #10
NeoPa
32,556 Expert Mod 16PB
Ah. That seems like a pretty top solution. From that, I can go over all you said and see that it did mainly make sense (albeit a little hard for me to follow).

I do like the solution though. Really quite neat.
Feb 2 '10 #11
bcr123
47
Thank you very much NeoPa.
Feb 2 '10 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Niyazi | last post by:
Hi, I have to retrieve a data from AS400 DB2 and after working with data I have to export into one of existing Excel file. I can connect into specific library in AS400 DB2 using AS400...
3
by: Carlos Magalhaes | last post by:
Hey All, I am doing some excel automation using the excel COM. I can do most of the functions and its working well until I come across a formula. I can run a formula and insert the formula...
6
by: Rich Wallace | last post by:
Hi all, I have a VB app that runs and manages individual XLS files within a single COM object. Upon processing the final fie, I attempt to close out the EXCEL object and release it using...
3
by: Esmael | last post by:
Hi to all... Goodmorning am working on a Project on VB6. THis is an excel automation... the VB6 Program reads from the Excel File and transfer the search data if found to another excel file......
3
by: toffee | last post by:
Hi all, I got a pre-formatted spreadsheet. would it be possible using js to copy the data from a table on the current webpage, open the spreadsheet and paste the content ? if so, anyone got any...
1
by: barnzee | last post by:
Hi all, newbie here, but having a go I am trying to build a stock watchlist in excel 2007 with a dynamic link to a DDE server (paid for from a broker).There is no add-in or plug-in, I just CTL ALT...
18
by: Dirk Hagemann | last post by:
Hello, From a zone-file of a Microsoft Active Directory integrated DNS server I get the date/time of the dynamic update entries in a format, which is as far as I know the hours since january 1st...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
0
by: Belsirk | last post by:
Hi, i'm using C# Visual Studio 2008 for made a apps able to take some information from the app and sending them to a excel template, i'm using Microsoft.Office.Interop.Excel namespace and i don't...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.