+ Reply to Thread
Results 1 to 10 of 10

formula to calculate %- differences for different categories, gender and age intervals

  1. #1
    Forum Contributor
    Join Date
    01-11-2013
    Location
    Sweden
    MS-Off Ver
    MS 365
    Posts
    188

    formula to calculate %- differences for different categories, gender and age intervals

    Hi all,

    I have a data table that contains some values. I need to calculate the %-differences per category, gender and age interval. I have 3 categories (AA;BB;CC), gender (F;M) and age interval (0-34;35-44;45-54;55-). Please see attached file for a better description.

    Is there a smart formula that can accomplish this? Hope someone can help me.

    /Masun
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    01-28-2014
    Location
    Brno
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: formula to calculate %- differences for different categories, gender and age intervals

    Hi,

    Solution enclosed. However, I would recommend you not to use merged cells unless you really have to.
    In this particular case I used function offset as workaround, but it only complicates whole formula.
    Attached Files Attached Files

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: formula to calculate %- differences for different categories, gender and age intervals

    Pepe74287... there may be a mistake somewhere, as your solution did not give the result anticipated by the OP.

    Here's a bit of a monster, based on SUMIFS (I'm not awke yet, so there's bound to be a neater way of doing this).

    BtW, I killed the dreaded merged cells, to keep the formulas simpler.
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU

  4. #4
    Registered User
    Join Date
    01-28-2014
    Location
    Brno
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: formula to calculate %- differences for different categories, gender and age intervals

    Glenn - Right, looks like I didn't pay attention.. Thanks for pointing this out. Enclosed is updated version.
    Attached Files Attached Files

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: formula to calculate %- differences for different categories, gender and age intervals

    At least we get the same answers now!!

  6. #6
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,941

    Re: formula to calculate %- differences for different categories, gender and age intervals

    Please remove leading spaces from Range K4 to K7
    =IFERROR(SUMPRODUCT((LOOKUP(Tabell4[Age],LEFT($K$4:$K$7,FIND("-",$K$4:$K$7)-1)+0,$K$4:$K$7)=$K4)*(Tabell4[Gender]=L$3)*(Tabell4[Category]=LOOKUP("zzzzzzzz",$L$2:L$2,$L$2:L$2))*(Tabell4[[New Sal]:[New Sal Extra]]-Tabell4[[Old sal]:[Old sal extra]]))/SUMPRODUCT((LOOKUP(Tabell4[Age],LEFT($K$4:$K$7,FIND("-",$K$4:$K$7)-1)+0,$K$4:$K$7)=$K4)*(Tabell4[Gender]=L$3)*(Tabell4[Category]=LOOKUP("zzzzzzzz",$L$2:L$2,$L$2:L$2))*(Tabell4[[Old sal]:[Old sal extra]])),"")
    Try this and copy across
    See the attached file
    Attached Files Attached Files
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  7. #7
    Forum Contributor
    Join Date
    01-11-2013
    Location
    Sweden
    MS-Off Ver
    MS 365
    Posts
    188

    Re: formula to calculate %- differences for different categories, gender and age intervals

    Hi,

    Wow. Thank you all!

    Pepe...Im not that familiar with the sumproduct function. How would it look if the categories are in separate cells and not merged? Please see attached. Would appreciate if you could show me.

    Once again...thanks!

    /M
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    01-28-2014
    Location
    Brno
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: formula to calculate %- differences for different categories, gender and age intervals

    You would simply replace this part "IF(ISBLANK(L$2),OFFSET(L$2,0,-1),L$2)" in formula with "L$2" and that's it.

    Let's say you merge cells L2&M2 into one. If you do that and refer to cell M2 (for *** M), excel consider cell M2 as blank cell. So with cells merged you need to first check whether cells from range L2:Q2 are blank (isblank part) and if yes, you need to take value from adjacent left cell - OFFSET(L$2,0,-1) which is in fact cell M$2.
    Hope it's more clear now.

  9. #9
    Forum Contributor
    Join Date
    01-11-2013
    Location
    Sweden
    MS-Off Ver
    MS 365
    Posts
    188

    Re: formula to calculate %- differences for different categories, gender and age intervals

    Yep, a little bit at least. I first tried SUMIFS but that formula i constructed turned more and more into a book and i realized that it had to be a better way. You provided one. Thanks!

  10. #10
    Registered User
    Join Date
    01-28-2014
    Location
    Brno
    MS-Off Ver
    Excel 2010
    Posts
    70

    Re: formula to calculate %- differences for different categories, gender and age intervals

    SUMPRODUCT has many advantages over COUNTIFS and SUMIFS - for instance enables you to use logical operators as AND and OR in quite intuitive way, also enables you to work with closed workbooks, it's also good for looking up values with more than one criteria - but also has one disadvantage - even if it's not an array function de jure (doesn't need to be entered with ctrl-shift-enter), de facto it is an array function, so using more SUMPRODUCT in one workbook (especially combined with large ranges) can cause significant slowness in processing.

    Anyway, it's really worth to get familiar with it.

+ 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] Formula to calculate date differences based on table data
    By Yossarian17 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-21-2014, 12:18 PM
  2. Formula to calculate time differences but not all cells have values?
    By claudiamariep in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-21-2014, 03:23 PM
  3. use of countif formula to calculate time intervals eg.15 min interval
    By sachin kokitkar in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-25-2013, 10:32 AM
  4. how to calculate average of different intervals
    By mrmoore90 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-29-2012, 10:35 AM
  5. Pivot Formula: Gender(male)/Gender(female)
    By peterso in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-04-2011, 04:23 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