+ Reply to Thread
Results 1 to 3 of 3

Slope, IF, Multiple Data Points

  1. #1
    Registered User
    Join Date
    06-10-2013
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2016
    Posts
    2

    Slope, IF, Multiple Data Points

    I'm trying to compute the slope of various products that have variable pricing ad quantity sources. The actual file is well over 5k rows and the product skus are in no particular order. I would like to input a slope formula with an IF statement that calculates the slope of only products that match that SKU.

    I thought adding an IF statement into the array and saying IF the array within Column A has the item in Column A, select only that value.

    {=SLOPE(IF($A$8:$A$20=$A8,$C$8:$C$20,),IF($A$8:$A$20=$A8,$B$8:$B$20,))}

    I'm trying to calculate the information in the yellow Column of the attached file. I provided a check column and am seeing differences with my calculation.

    Any help is greatly appreciated!
    Attached Files Attached Files

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

    Re: Slope, IF, Multiple Data Points

    SLOPE() ignores boolean, text, and other non-numeric data, but it will include 0 values in the regression. These kind of array functions work by replacing the "values to be ignored" with some kind of non-numeric data in the input array (usually FALSE or empty string ""). The first thing I did to debug is to use the evaluate formula tool to see what the IF() array functions are returning and see if it looks right. https://support.office.com/en-us/art...6-a70aa409b8a7 Follow along in your own copy of Excel.

    1) Select D8 and call up the evaluate formula tool
    2) Step through each step of the function until it evaluates the first IF() array.
    3) Note the results of the array (fortunately, your arrays are small enough to fit in the small window MSFT provides). We are expecting a list of 5 numbers followed by FALSE or something. When I run it, I get a bunch of 0's. As noted, 0 values are included in the regression.
    4) The problem is that the IF() is returning 0 for the value_if_false argument of the IF() functions instead of something else. The solution, then, is to fix the IF() functions so they return a non-numeric value that SLOPE() can ignore.
    4a) I note that most IF() arrays do not include the comma preceding the value_if_false argument, but yours do. Try removing the extra comma to see if that causes the IF() function to return FALSE. IF($A$8:$A$20=$A8,$C$8:$C$20)
    4b) Many times I don't like to leave an optional argument blank if there is any question in my mind that Excel might default to something I don't want. Try explicitly entering something into the value_if_false argument IF($A$8:$A$20=$A8,$C$8:$C$20,"ignore")

    Hopefully that not only helps you resolve this problem, but helps you see how to debug and find these same kinds of problems in the future.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Registered User
    Join Date
    06-10-2013
    Location
    Charlotte, NC
    MS-Off Ver
    Excel 2016
    Posts
    2

    Re: Slope, IF, Multiple Data Points

    Thank you for the reply! This helps me tremendously and I really appreciated that guidance of how you "evaluated" the formula with Excel.

    The "0"s being returned were 100% the issue and I appreciate the minor adjustment.

    Updated formula now states {=SLOPE(IF($A$8:$A$20=$A8,$C$8:$C$20),IF($A$8:$A$20=$A8,$B$8:$B$20))}

+ 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. Replies: 6
    Last Post: 04-11-2017, 08:55 AM
  2. [SOLVED] Find The Slope of Three Points
    By artiststevens in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 01-31-2016, 07:43 AM
  3. Replies: 3
    Last Post: 01-23-2014, 03:19 PM
  4. Need macro to search multiple data points from multiple entries and return single value
    By Redbullmoo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-11-2013, 02:16 AM
  5. Calculating Slope and Intercept with a changing number of data points
    By WE5T in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-10-2013, 05:48 AM
  6. Compare multiple data points in row _ multiple sheets _ output different information
    By floydian in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-18-2013, 08:52 AM
  7. slope of a set of points
    By jcody in forum Excel General
    Replies: 3
    Last Post: 09-20-2012, 10:10 AM

Tags for this Thread

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