+ Reply to Thread
Results 1 to 3 of 3

Combining Percentile, IF functions with Positive and Negative values

  1. #1
    Registered User
    Join Date
    08-29-2018
    Location
    California
    MS-Off Ver
    Office 365
    Posts
    12

    Combining Percentile, IF functions with Positive and Negative values

    Hi,

    So I have a spreadsheet of weekly opening and closing prices for a stock.
    I'm trying to combine a Percentile function with an IF function on a range that has positive and negative values.

    Here's my current formula:
    =ROUND(PERCENTILE.INC(IF($M:$M=$AB$1,$L:$L,),Y$2+0.01),2)

    M column indicates if the week finished up or down.
    L column gives the change in value for the week, value positive if week was up, negative if week was down
    AB1 is the cell where I select up or down to choose which data set I want to see the values of.
    Y2 is the cell where I set the percentage value that I want the Percentile function to calculate.

    Current results:
    When I set AB1 to Up, this formula appears to work well.
    When I set AB1 to Down, this formula returns 0 instead of a negative number.
    When I use Alt+Shift+Enter, this formula returns 0 regardless if I have AB1 set to Up or Down.

    I tried searching for available solutions on this board and others, but none that I've tried has worked.
    Based on one solution I saw, I tried putting in ABS(L:L), but that gave me an error.
    Another solution I saw, I tried to put 1-Y2 for negative values, but that returned 0 for me as well.

    I'm not sure what I'm doing wrong.
    Any help would be greatly appreciated.
    Last edited by VenatusNocte; 08-29-2018 at 05:01 PM. Reason: solved

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

    Re: Combining Percentile, IF functions with Positive and Negative values

    When I put that formula (without the .INC, since I don't have that version of the PERCENTILE() function in my version of Excel) into a cell and step through the function with the Evaluate formula tool https://support.office.com/en-us/art...6-a70aa409b8a7 I see that Excel evaluates the IF() array with the value or the number 0. Of course, the number 0 is a perfectly fine number to include in a percentile calculation, and there are could be about a million 0's (since you are using full column references), so just about any percentile of a million data points where almost all of the data points are 0 is going to be 0.
    A couple of edits that may fix this:
    1) By removing the comma that would delimit the "value if FALSE" argument from the IF() function, I can get the IF() array to return the boolean FALSE for those entries that do not match your criteria. PERCENTILE() will ignore these boolean values, so it should return the correct result. ...IF($M:$M=$AB$1,$L:$L)...
    2) Don't leave the "value if FALSE" argument blank. Specify a text string or boolean value for it to return. ...IF($M:$M=$AB$1,$L:$L,"not")

    One of those should work. I would expect that you need to array enter this kind of function (ctrl-shift-enter). You may also want to consider whether you need full column references. Also remember that, for negative numbers, "small" numbers are farther from 0 (-1 is less than -0.5 is less than -0.2 is less than 0), in case you are expecting the first quartile to be closer to 0 than the third quartile.
    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
    08-29-2018
    Location
    California
    MS-Off Ver
    Office 365
    Posts
    12

    Re: Combining Percentile, IF functions with Positive and Negative values

    OMG, leaving out the FALSE argument never even crossed my mind. I tried it and ran a few tests and it works. Thank you!

+ 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: 10
    Last Post: 09-24-2018, 09:26 AM
  2. [SOLVED] Sum positive and negative values
    By Nutzman in forum Excel General
    Replies: 4
    Last Post: 12-09-2017, 10:19 AM
  3. [SOLVED] Median, Percentile, Min functions which can handle #N/A values
    By moty.98 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-18-2012, 09:04 AM
  4. Looking for a positive value ABOVE negative values
    By ckatzman in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-05-2012, 08:54 PM
  5. Replies: 8
    Last Post: 07-28-2012, 03:22 PM
  6. Convert negative to positive in sheet containing both positive/negative numbers
    By sa02000 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-29-2010, 07:52 PM
  7. Replies: 4
    Last Post: 09-26-2005, 06:05 PM

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