+ Reply to Thread
Results 1 to 15 of 15

muti vaient formula

  1. #1
    Registered User
    Join Date
    01-21-2016
    Location
    uk
    MS-Off Ver
    2010
    Posts
    10

    muti vaient formula

    hi all
    in the attached file, a variable is measured every hour throughout the day, every day.
    values measured are maximum and minimum.
    i would like to formulate F such that the first touch will show 1 for the first time either max or min will be equal or cross the standard for the day.
    equality is when value is within a difference of 1. for example if the standard for the day is 100, first touch would be when the maximum is 99 or greater or minimum is 101 and smaller.

    i am only interested in the first time this happens in the day, for either the maximum or the minimum, whichever first, but not both
    i have highlighted in yellow the three cells that fit the criteria

    currently F has a formula suggested by someone in another forum, which works but only for equality or proximity (i.e to within 1 difference) but not for crossing. it also gives back bingo rather than 1, and if i try changing it to "1" it stops working

    any help would be greatly appreciated
    thanks
    Attached Files Attached Files

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,731

    Re: muti vaient formula

    The formula in column F is an array formula, which means that it has to be confirmed using the key combination of Ctrl-Shift-Enter (CSE), rather than the usual |Enter|, and if the formula is amended then CSE has to be used again. If this is done correctly then you will be able to see curly braces { } around the formula when viewed in the formula bar, though you should not type these yourself.

    You can amend the formula in F2 to this:

    =IF(ROW()=MIN(IF((A2=A$2:A$100)*((ABS(E2-C$2:C$100)<=1)+(ABS(E2-D$2:D$100)<=1)),ROW($2:$100))),1,"")

    and use CSE to confirm it, and then the formula can be copied down in the usual way(s) (e.g. double-click the fill handle - bottom right-hand corner of the cursor)

    Hope this helps.

    Pete

  3. #3
    Registered User
    Join Date
    01-21-2016
    Location
    uk
    MS-Off Ver
    2010
    Posts
    10

    Re: muti vaient formula

    thanks, yes i had CSE in use. now i do get one, but the formula need twitching to show crossing. for example in the doc i sent F12 should get 1 and not F13
    any suggestions would be greatly appreciated
    thanks

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: muti vaient formula

    Here's an attempt. I am not a fan of large single cell mega formulas, so I have spread the logic out over several columns.

    Since the difference between each entry and that days standard is important, there are two columns (H:I) to compute the difference between each entry (max and min) and the standard.

    The logical tests seem to be about checking, in two separate columns (J:K):
    is max and/or min within one of standard
    has max or min "crossed" standard (checked by seeing when difference changes sign).


    The final result for each day is the first row where either of the above conditions is true. Column L checks when either condition is true, and then the match() functions in column M return the row # of the first TRUE result for each day.

    Since I am not a fan of single cell mega formulas, I will leave it to someone else to nest all of that into a single formula. This shows how I would structure a spreadsheet like this, and should also allow you to confirm that the logic I have read into the question is correct (if someone does choose to undertake the single cell megaformula).
    Attached Files Attached Files
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Registered User
    Join Date
    01-21-2016
    Location
    uk
    MS-Off Ver
    2010
    Posts
    10

    Re: muti vaient formula

    very nice, thanks. seems to be very accurate, and gives back the row number which works to be the hour value, exactly what needed, thanks
    can i please push you further?
    what i forgot to mention is that on some days the max/min dont get to or cross the standard, for the purpose here lets call it a failure. Your file correctly identifies those failures giving back # N/A. this interfere with stats, since if for example i want to study the average time crossing occurs each day, i cannot average the values in M as N/A interferes.
    so now i need a new columns that will only show the values of first true and ignore the failure, and another column that will look for the failures and give a return of 1 when it happens

    many thanks
    you are very helpful

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: muti vaient formula

    Most people would assume that "not found" or N/A is the only error that would be returned, and will use the IFERROR() function: https://support.office.com/en-us/art...6-63f3e417f611

  7. #7
    Registered User
    Join Date
    01-21-2016
    Location
    uk
    MS-Off Ver
    2010
    Posts
    10

    Re: muti vaient formula

    thanks
    i have managed to sort this in a different way.
    problem is i go through the data now to find mistakes that i cannot explain
    have highlighted in yellow days when a mistake occurs and in green what supposed to be the result
    i cannot find why would excel make the mistake, though i know it is not always the most clever in simple math
    any suggestions?
    many thanks again
    Attached Files Attached Files

  8. #8
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: muti vaient formula

    The "changes sign" formula in column L is looking at the current and the previous row. In the case of row 650 (and probably others that return 1), the formula in column L is comparing the sign of the first entry for the current day with the last entry for the previous day. These comparisons are probably invalid comparisons. "Simply" add another "criteria" column to check if this is the first entry for a given day and take appropriate action.

    Or, is it possible that the first entry of a given day will never be the correct result? We could have the MATCH() functions start their search with the 2nd entry for each day, if we (you) can state with absolute certainty that the first entry of the day will never be the result we should receive. For example, in row 434, you indicate that this day should have returned the 1st entry, but I cannot see the logic that says this should be the first entry instead of the 2nd entry.

    So, in this case, Excel is not making a mistake. Excel is doing exactly what we (I) have told it to do. In order to get Excel to give a different result, we need to think carefully through the logic we need Excel to use and take appropriate action.

  9. #9
    Registered User
    Join Date
    01-21-2016
    Location
    uk
    MS-Off Ver
    2010
    Posts
    10

    Re: muti vaient formula

    thanks
    i am sure you are right
    the data is practically entered in blocks of 24 lines for each day. essential to note that each friday the entry ends at 21pm and resumes on sunday to complete the block of 24 lines. if i did what you suggested i am guessing it will cause further mistakes
    as such, is there a way to look at the data in blocks of 24 lines rather then dates?
    thanks

  10. #10
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: muti vaient formula

    Not only is there "a" way to look at data in blocks of 24 lines, there likely many different strategies.

    One that I frequently use is to enter the data in blocks of 24. Instead of a long list of entries like you have here, I will often arrange the data in a table that might look something like:
    Please Login or Register  to view this content.
    My analysis formulas will then go into the rows below each data set, until I get my final result towards the bottom. Because I don't like to scroll to the bottom to see the final result, I will usually have that link to somewhere near the top (maybe row 26, since the data is in rows 2:25). If I pay careful attention to these formulas, I can then simply copy these formulas across to perform the analysis for each day.

    Where you have already entered your data into a long list, you may not want to rearrange it, or there is some other consideration that makes a long list preferable. In those cases, you may want additional IF() functions to test for "start of day" and/or "end of day". The Time column (column B) might be the easiest column to look at. You might use something like
    =IF(B2=0,what do do for the 1st entry of a day,what to do for other entries of a day).

  11. #11
    Registered User
    Join Date
    01-21-2016
    Location
    uk
    MS-Off Ver
    2010
    Posts
    10

    Re: muti vaient formula

    thanks, i cannot take anymore of your time. i understand everything you say but i cannot solve the problem here. these are excel functions that are way above my understanding..
    will try and think about it a bit more, but i cannot see how to change the possible problemtic formula

    many thanks anyway

  12. #12
    Registered User
    Join Date
    01-21-2016
    Location
    uk
    MS-Off Ver
    2010
    Posts
    10

    Re: muti vaient formula

    wow, i made it. see attached file. used some of your formulae but changed the tests.
    looks to be working fine now but i still have mistakes which i have diagnosed as problems in source of data. apparently some data is sometimes is missing or duplicates. see rows 1079-1080
    and 5882-5883 for duplicated hourly entry or missing hourly entries
    apart from the tedious scrolling through the data how can i ask excel to check for these? can it bring back list of cell? rows? or just highlighted cells?
    many thanks
    Attached Files Attached Files

  13. #13
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: muti vaient formula

    how can i ask excel to check for these? can it bring back list of cell? rows? or just highlighted cells?
    I'm sure there are many possible strategies.

    We have not talked at all about where these data come from or how they get into Excel. In some cases, I find that identifying and dealing with these kind of errors is easier if handled before importing the data to Excel. At this point, only you can know if that is the case here.

    If I must handle these errors in Excel, I might start with a strategy like this:

    1) Boolean tests and operations to identify the error conditions. You the programmer/developer will need to know what kind of "errors" might exist so you can test for them all (and there is probably a development process involving some "oh, there's a new error I had not anticipated"). I am not sure of the logic in identifying the errors you have highlighted. Perhaps "is the difference in times in column C anything but 1 hour" (=round(C3-C2,8)<>1 -- the round() function is there to capture any potential round off error due to binary arithmetic).
    2a) With the boolean logic in place to identify the error conditions, you might choose to use Conditional Formatting to highlight the rows where the errors exist. Can I assume you are familiar with conditional formatting? If not, there are several tutorials on the internet or in your help files that describe how to use conditional formatting.
    2b) With the boolean logic in place in the spreadsheet, you can use the Autofilter tool (Data Tab) to display only those rows that are flagged with the error. Again, can I assume you are familiar with autofilter? If not, search your help files for autofilter and you should find help for creating filtered lists.
    3) Deal with these errors as you see fit. You have not explained what you want to do with these errors. If you have trouble dealing with these errors in the way you want, let us know and we'll see what suggestions we can make.

  14. #14
    Registered User
    Join Date
    01-21-2016
    Location
    uk
    MS-Off Ver
    2010
    Posts
    10

    Re: muti vaient formula

    thanks, will have a go
    basically if there is a double entry it needs to be removed (don't care which one)
    more difficult situation will be for missing data, i think that adding the appropriate missing rows would be enough, as it will keep the rest of the sheet in line
    thanks again

  15. #15
    Registered User
    Join Date
    01-21-2016
    Location
    uk
    MS-Off Ver
    2010
    Posts
    10

    Re: muti vaient formula

    thanks, will have a go
    basically if there is a double entry it needs to be removed (don't care which one)
    more difficult situation will be for missing data, i think that adding the appropriate missing rows would be enough, as it will keep the rest of the sheet in line
    thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] VBA Macro FUNCTION To Sum Up Values of multiplier of muti-Columns
    By tungtran.ftu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2015, 12:53 AM
  2. Replies: 11
    Last Post: 06-06-2014, 03:34 PM
  3. how to hide formula in formula box, view lookup result in formula box?
    By vengatvj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-14-2013, 04:06 PM
  4. *** Simple Muti-Series Line Graph ***
    By exceltoohard in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 08-06-2013, 01:46 AM
  5. Muti find & replace function
    By junada0 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-04-2010, 02:34 AM
  6. Formulas for creating a muti-unit 12 mo. bugdet using a 1 store mo
    By JTack in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-29-2005, 09:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1