+ Reply to Thread
Results 1 to 6 of 6

An ugly % variance formula needs help to be pretty

  1. #1
    Registered User
    Join Date
    09-26-2019
    Location
    Phoenix, AZ
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2303 Build 16.0.16227.20202) 64-bit
    Posts
    78

    An ugly % variance formula needs help to be pretty

    I have an ugly formula for percent variance that I have been trying to clean up for a financial report, but I'm hitting walls with it. One big wall is making sure that google sheets likes it too.

    I would love some help and insight (other than using C-4...I've already thought of that.)

    Thank you,
    Attached Files Attached Files
    "Stairs, they are always up to something."

  2. #2
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: An ugly % variance formula needs help to be pretty

    You can do it with conditional format.
    mark your range-->go to format cells-->custom--> copy this 0;-0;;@

  3. #3
    Registered User
    Join Date
    09-26-2019
    Location
    Phoenix, AZ
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2303 Build 16.0.16227.20202) 64-bit
    Posts
    78

    Re: An ugly % variance formula needs help to be pretty

    Unfortunately, it doesn't take into consideration that the powers that be "DEMAND" that "N/A"
    .

  4. #4
    Valued Forum Contributor loginjmor's Avatar
    Join Date
    01-31-2013
    Location
    Cedar Rapids, Iowa
    MS-Off Ver
    Excel 2013
    Posts
    1,073

    Re: An ugly % variance formula needs help to be pretty

    Hi -

    When I have several criteria that I am testing against, instead of hard coding those into a formula, I usually make a little look up table and use, you guessed it, VLOOKUP, or INDEX/MATCH to do the testing for me. It keeps a lot of those pesky IF statements out of there, and eliminates the sneaky logic errors you can run into with multiple, nested IF statements. So, over to the side of your table (or you could put it on a separate sheet) I have created a table for the various values of Column D versus Column G. So, for example, if I'm reading your formula correctly, if the value in Column D is <0, the answer is always NA. If D is 0 and G is >0, NA. If D > 0 and G is 0, NA. Otherwise, calculate the percentage of the two values (apparently if both are 0, you want 0 to display, not DIV/0!, so I added the IFERROR test to catch that). The last part is to check if it's outside the range of -9.999 to +9.999 which I just do an absolute value and test it once.

    Anyway, the formula in H11 looks like:

    =IFERROR(IF(VLOOKUP(D11,$L$10:$P$12,MATCH(G11,$L$9:$P$9),TRUE)="NA","NA",IF(ABS((D11-G11)/ABS(G11))>9.999,"NA",(D11-G11)/ABS(G11)))*C11,0)

    Where $L$10:$P$12 is my little look up table. Attached is your spreadsheet with everything above included. One other note, using a table, rather than hardcoding your test paramaters, allows you to change those parameters easily a year later after you've forgotten what you put in there and what all formulas reference those parameters. Just makes your life easier later. I would also suggest you put your 9.999 testing criteria in a cell, rather than coding into your formula. I intentionally didn't do that as I didn't want to muddy the waters more than I have.

    Hope this helps.
    Attached Files Attached Files
    ____________________________________________
    If this has solved your problem, please edit the thread title to add the word [SOLVED] at the beginning. You can do this by
    -Go to the top of the first post
    -Select Thread Tools
    -Select Mark thread as Solved

    If I have been particularly helpful, please "bump" my reputation by pressing the small star in the lower left corner of my post.

  5. #5
    Registered User
    Join Date
    09-26-2019
    Location
    Phoenix, AZ
    MS-Off Ver
    Microsoft? Excel? for Microsoft 365 MSO (Version 2303 Build 16.0.16227.20202) 64-bit
    Posts
    78

    Re: An ugly % variance formula needs help to be pretty

    That makes the most sense, let's see if the powers that be are interested.

  6. #6
    Valued Forum Contributor loginjmor's Avatar
    Join Date
    01-31-2013
    Location
    Cedar Rapids, Iowa
    MS-Off Ver
    Excel 2013
    Posts
    1,073

    Re: An ugly % variance formula needs help to be pretty

    Thanks for the rep!

+ 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: 1
    Last Post: 08-01-2016, 09:07 PM
  2. Replies: 2
    Last Post: 07-05-2016, 06:54 PM
  3. toggle between variance in units and % variance
    By ammartino44 in forum Excel General
    Replies: 3
    Last Post: 06-03-2014, 07:21 PM
  4. [SOLVED] Find the date of a variance amount over a limit and count the days since the variance.
    By avidcat in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 06-21-2013, 12:00 PM
  5. Price Variance and Dollar Variance for multiple stores on certain products
    By hutchgeo4 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 02-22-2013, 05:49 PM
  6. SUMPRODUCT formula:pretty simple formulae
    By BUSJEDWA in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-22-2008, 08:59 AM
  7. Pivot Tables - Variance and % Variance fields
    By CraigS in forum Excel General
    Replies: 5
    Last Post: 01-05-2005, 09:06 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