+ Reply to Thread
Results 1 to 7 of 7

Need your help understanding how excel iterates through data sets in formulas

  1. #1
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    Need your help understanding how excel iterates through data sets in formulas

    I have an array formula which I am attempting to have ignore some bad data in cells which is usually text. Right now, as long as I have text in a few of these cells it is throwing a #VALUE at the end of evaluation. I am using the "Show Calculation Steps" feature to step through the evaluation of the formula and it brought me to the question of "How does excel iterate through multiple rows when it is processing a formula?"

    Here is my formula

    =AVERAGE(IF(AND(Categories1[Column1]="T&M",NOT(ISERROR(Categories1[Check]))),PRODUCT(QUOTIENT(IF(ISERROR(Categories1[PO Amount - Labor]),0,Categories1[PO Amount - Labor]),IF(ISERROR(Categories1[SUB Daily Rate]), 1, Categories1[SUB Daily Rate])),8),""))

    Having a programming background what I would expect to happen here is that the formula would run like a FOREACH loop on each row of the range. But, the way the Formula evaluator is displaying it's steps makes me question that. I will try to explain below as best I can.

    It starts by performing as I would expect and evaluating whether the cells in Column1 = T&M or not. So I get a set of TRUE's and FALSE's
    1.jpg

    Clicking "Evaluate" again shows that ISERROR finds two #VALUE errors and the rest of the data is 0 or not an error.
    2.jpg

    ISERROR then does what I would expect and evaluates to TRUE, TRUE and then all FALSE's
    3.jpg

    That get's NOTed to be FALSE, FALSE and then a bunch of TRUE's...again, what I would expect
    4.jpg

    This next step is what I didnt expect. I thought it would then iterate through each row and take the combination of a (TRUE, FALSE) for row 1 and skip it. Then the combination of (TRUE, FALSE) for row 2 and skip it. Then a (TRUE, TRUE) and evaluate the rest of the formula for an average. But, instead, it seems to evaluate the IF for the entire formula to a FALSE and bail out.
    5.jpg

    on the next step it errors and produces a #VALUE for the entire formula.
    \1

    I either dont understand something here or, I am doing something wrong...or both.

    Any input would be greatly appreciated.

    Thanks,

    josh
    Last edited by JBeaucaire; 05-24-2013 at 04:57 PM.

  2. #2
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Need your help understanding how excel iterates through data sets in formulas

    I cannot help you with how Excel thinks, not being a programmer. However, I do know that when working with Array formulas, Excel doesn't like AND statements. I would exchange it for a nested IF. I'm not sure if I have all the parentheses in the right place but something like this

    =AVERAGE(IF(Categories1[Column1]="T&M",IF(NOT(ISERROR(Categories1[Check])),PRODUCT(QUOTIENT(IF(ISERROR(Categories1[PO Amount - Labor]),0,Categories1[PO Amount - Labor]),IF(ISERROR(Categories1[SUB Daily Rate]), 1, Categories1[SUB Daily Rate])),8),"")))
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  3. #3
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: Need your help understanding how excel iterates through data sets in formulas

    Great. Thanks. That is good to know.

    The formula is now picking up some fields that have text where numbers should be. My understanding was that using QUOTIENT would prevent that and was a good alternative to using "/" for division. Any ideas what I am doing wrong here?



    Ive attached my dataset
    Attached Files Attached Files

  4. #4
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Need your help understanding how excel iterates through data sets in formulas

    Can you briefly describe what you're trying to average? Not in formula-speak, just in English...
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  5. #5
    Registered User
    Join Date
    05-23-2013
    Location
    California
    MS-Off Ver
    Excel 2013
    Posts
    68

    Re: Need your help understanding how excel iterates through data sets in formulas

    Quote Originally Posted by JBeaucaire View Post
    Can you briefly describe what you're trying to average? Not in formula-speak, just in English...
    Sure! I am trying to first figure out how many hours each contract was for (Total amount / daily rate) and then average the total number of hours for each contract.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Need your help understanding how excel iterates through data sets in formulas

    Column C is the contract?

    So, for each row that has T&M in column C, sum give the average of value from B/D, not including rows with an error in column B?

  7. #7
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Need your help understanding how excel iterates through data sets in formulas

    Does this array give you what you want?

    =AVERAGE(IF(NOT(ISERROR(Categories1[Check]))+(Categories1[Column1]="T&M")=2, Categories1[Check]/Categories1[Rate/day]))
    Last edited by JBeaucaire; 05-24-2013 at 08:18 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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