+ Reply to Thread
Results 1 to 15 of 15

Summarize data on multiple criteria

  1. #1
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Summarize data on multiple criteria

    I give up !

    I tried a lot to have a common formula to take care of multiple conditions which will produce the desired result but I failed miserably and thought of trying some luck here if anyone can guide me in this. File attached.

    Setup
    Raw data is in "Data" Sheet
    Filters are placed in range C3:E4
    Formulas needed in range D7:E18

    Criteria
    1. When all three filters has values as NA: range D7:E18 should show an overall total - This was very simple and is done already. I am struggling with the remaining three conditions.
    2. When Year is selected keeping Month and Date value as NA: range D7:E18 should fill up with count only for selected year. Month and Date filter would then be unavailable. This will show yearly report.
    3. When Year and Month are selected keeping Date value as NA: range D7:E18 should fill up with count only for selected month and year. This will show monthly report.
    4. When Year, Month and Date all filters are selected: range D7:E18 should fill up with count only for that selected date. This will show daily report.

    Appreciate some help. Thanks.

    EDIT: I can achieve this with a pivot but I dont need that for some reasons known only to me. I need to work on this report furher after achieving the desired result.
    Attached Files Attached Files
    Last edited by sabha; 01-19-2017 at 10:05 AM.

  2. #2
    Registered User
    Join Date
    10-13-2013
    Location
    China
    MS-Off Ver
    Excel 2011
    Posts
    15

    Re: Summarize data on multiple criteria

    Input this into cell D7:
    =IF(AND($C$4="NA",$D$4="NA",$E$4="NA"),SUMIF(Data!D$2:D$160,$C7,Data!$L$2:$L$2160),IF($D$4="NA",SUMIFS(Data!$L$2:$L$160,Data!D$2:D$160,$C7,Data!$A$2:$A$160,$C$4),IF(E4="NA",SUMIFS(Data!$L$2:$L$160,Data!D$2:D$160,$C7,Data!$A$2:$A$160,$C$4,Data!$B$2:$B$160,$D$4),SUMIFS(Data!$L$2:$L$160,Data!D$2:D$160,$C7,Data!$A$2:$A$160,$C$4,Data!$B$2:$B$160,$D$4,Data!$Q$2:$Q$160,$E$4))))

    Input this into cell E7:
    =IF(AND($C$4="NA",$D$4="NA",$E$4="NA"),SUMIF(Data!D$2:D$160,$C7,Data!$E$2:$E$160),IF($D$4="NA",SUMIFS(Data!$E$2:$E$160,Data!D$2:D$160,$C7,Data!$A$2:$A$160,$C$4),IF(F4="NA",SUMIFS(Data!$E$2:$E$160,Data!D$2:D$160,$C7,Data!$A$2:$A$160,$C$4,Data!$B$2:$B$160,$D$4),SUMIFS(Data!$E$2:$E$160,Data!D$2:D$160,$C7,Data!$A$2:$A$160,$C$4,Data!$B$2:$B$160,$D$4,Data!$Q$2:$Q$160,$E$4))))

  3. #3
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Re: Summarize data on multiple criteria

    Thank you for your reply. It will take some time for me to understand the exact working of this formula. Meanwhile, I thought of testing it and here are my observations:
    1. This criteria was already working
    2. It works without any issues
    3. If I select 2016 Dec or 2017 Jan, it fills up only values for name "SN" in row7. The rest of the rows are blank. This should ideally show monthwise count for all names for the month of Jan in 2017
    4. If I select all three filters. For instance 2017 Jan and 1 as date, it shows zero values for all names. This criteria does not work at all. This should ideally show daywise count for all names for 1st Jan 2017

  4. #4
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Summarize data on multiple criteria

    I think there is a built-in feature (Pivot Table) which suits your need.This will eliminate the chances of duplicates as you have mentioned Name PS 2 times in your report,
    See if this helps this?
    Attached Files Attached Files
    Teach me Excel VBA

  5. #5
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Re: Summarize data on multiple criteria

    Quote Originally Posted by excelisfun009 View Post
    I think there is a built-in feature (Pivot Table) which suits your need.This will eliminate the chances of duplicates as you have mentioned Name PS 2 times in your report,
    See if this helps this?
    Yes I understand pivot table does the work but I am looking for a formula based solution (if there is any) as demanded by the end user. I mentioned it in my original post as an EDIT. I initially tried the pivot way but the user does not want to keep shuffling the fields and need a very easy way of dropdowns and since then I am breaking my head on this.
    And yes, sorry for the two identical names "PS"

  6. #6
    Registered User
    Join Date
    10-13-2013
    Location
    China
    MS-Off Ver
    Excel 2011
    Posts
    15

    Re: Summarize data on multiple criteria

    Sorry, my first posting was incomplete and little bit incorrect. Try this:

    First there were some small errors in my formulas, but I think I've fixed them here:
    In cell D7 input this:
    =IF(AND($C$4="NA",$D$4="NA",$E$4="NA"),SUMIF(Data!D$2:D$160,$C7,Data!$L$2:$L$160),IF($D$4="NA",SUMIFS(Data!$L$2:$L$160,Data!D$2:D$160,$C7,Data!$A$2:$A$160,$C$4),IF($E$4="NA",SUMIFS(Data!$L$2:$L$160,Data!D$2:D$160,$C7,Data!$A$2:$A$160,$C$4,Data!$B$2:$B$160,$D$4),SUMIFS(Data!$L$2:$L$160,Data!D$2:D$160,$C7,Data!$A$2:$A$160,$C$4,Data!$B$2:$B$160,$D$4,Data!$Q$2:$Q$160,$E$4))))

    In Cell E7 input this:
    =IF(AND($C$4="NA",$D$4="NA",$E$4="NA"),SUMIF(Data!D$2:D$160,$C7,Data!$E$2:$E$160),IF($D$4="NA",SUMIFS(Data!$E$2:$E$160,Data!D$2:D$160,$C7,Data!$A$2:$A$160,$C$4),IF($E$4="NA",SUMIFS(Data!$E$2:$E$160,Data!D$2:D$160,$C7,Data!$A$2:$A$160,$C$4,Data!$B$2:$B$160,$D$4),SUMIFS(Data!$E$2:$E$160,Data!D$2:D$160,$C7,Data!$A$2:$A$160,$C$4,Data!$B$2:$B$160,$D$4,Data!$Q$2:$Q$160,$E$4))))

    Drag these formulas down to copy them to all of the rows corresponding to the names.

    Now, go into your data sheet and in cell Q2 input this formula:
    =TEXT(C2,"dd")

    Drag that down to copy to all of the rows.

    Now, I think your table should populate with the figures you want.

    Let me know if that works out for you.

  7. #7
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,215

    Re: Summarize data on multiple criteria

    In D7

    IF(AND($C$4="NA",$D$4="NA",$E$4="NA"),SUMIF(Data!D$2:D$160,$C7,Data!$L$2:$L$2160),IF($D$4="NA",SUMIFS(Data!$L$2:$L$160,Data!D$2:D$160,$C7,Data!$A$2:$A$160,$C$4),IF($E$4="NA",SUMIFS(Data!$L$2:$L$160,Data!D$2:D$160,$C7,Data!$A$2:$A$160,$C$4,Data!$B$2:$B$160,$D$4),SUMIFS(Data!$L$2:$L$160,Data!D$2:D$160,$C7,Data!$A$2:$A$160,$C$4,Data!$B$2:$B$160,$D$4,Data!$Q$2:$Q$160,$E$4))))

    Highlighted E4 should be absolute

    same for formula in E7

    and Column Q is a helper

    =DAY(C2) copy down

  8. #8
    Registered User
    Join Date
    10-13-2013
    Location
    China
    MS-Off Ver
    Excel 2011
    Posts
    15

    Re: Summarize data on multiple criteria

    Haha, oh yeah! "Column Q is a helper" all right. :-)

  9. #9
    Valued Forum Contributor ImranBhatti's Avatar
    Join Date
    03-27-2014
    Location
    Rawalpindi,Pakistan
    MS-Off Ver
    Office 365
    Posts
    1,784

    Re: Summarize data on multiple criteria

    John Topley & SamulMRoth both Rocked..........
    Ahsome solutions indeed....

  10. #10
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Re: Summarize data on multiple criteria

    @SamuelMRoth
    Wonderful!
    Now this is going to take good time for me to breakup the formula and understand the logic. I am definitely going to do that. Thank you so much !

    1. I was also looking at auto sorting the data based on Total whenever there is a change in the filters. Do you think I should go for vba or use Rank/Match with helping columns to sort it?
    2. Presently the time is shown in minutes. If I want to show the time in true time format hh:mm:ss then is it better to edit your formula to get the result or should I use helper column in my Data sheet to convert it?
    Appreciate if you can advise me on the above two queries. Thanks

    EDIT: I guess I must avoid vba coz the end user is not so proficient as he would need to enable macros which he may not be good at!
    Last edited by sabha; 01-19-2017 at 12:47 PM. Reason: just a thought in EDIT

  11. #11
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Re: Summarize data on multiple criteria

    Quote Originally Posted by excelisfun009 View Post
    John Topley & SamulMRoth both Rocked..........
    Ahsome solutions indeed....
    @JohnTopley
    Thanks for highlighting the absolute and bringing it to my notice. It helps when the formula is too big

  12. #12
    Registered User
    Join Date
    10-13-2013
    Location
    China
    MS-Off Ver
    Excel 2011
    Posts
    15

    Re: Summarize data on multiple criteria

    @sabha
    I really don't know. I don't think I've ever worked with anything that auto sorts based on changing criteria.

  13. #13
    Forum Contributor
    Join Date
    11-29-2014
    Location
    India
    MS-Off Ver
    MS Excel 2007
    Posts
    240

    Re: Summarize data on multiple criteria

    NO issues! You have helped me a lot.
    Let me know what would you want to suggest on point no.2 of showing the time in time format than in minutes.

  14. #14
    Registered User
    Join Date
    10-13-2013
    Location
    China
    MS-Off Ver
    Excel 2011
    Posts
    15

    Re: Summarize data on multiple criteria

    I think I would probably try to get the data sheet to provide the times in seconds in column L, then when it is summarized in the report sheet have it formatted to display hh:mm:ss . That's just my initial idea about how to approach it though.

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,215

    Re: Summarize data on multiple criteria

    In E of "Report"

    =TIME(INT(SUMIF(Data!$D$2:$D$160,C7,Data!$E$2:$E$160)/60),MOD(SUMIF(Data!$D$2:$D$160,C7,Data!$E$2:$E$160),60),0)

    format cell as [h]:mm

+ 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. Summarize Based on Multiple Criteria
    By Kumara_faith in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 06-28-2015, 10:23 AM
  2. Summarize Multiple Worksheets Based on Criteria
    By xybadog in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 06-02-2014, 11:28 AM
  3. Replies: 8
    Last Post: 10-27-2011, 05:43 PM
  4. Summarize data from multiple worksheets
    By jarssonn in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-29-2010, 12:47 PM
  5. Summarize data based on multiple criteria
    By sigil in forum Excel General
    Replies: 3
    Last Post: 01-06-2010, 08:56 PM
  6. Summarize Data using Multiple Criteria
    By karstens in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-15-2008, 06:51 PM
  7. how do i summarize data in multiple workbooks?
    By Norman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-11-2005, 05:25 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