+ Reply to Thread
Results 1 to 15 of 15

Can you add a condition to a MAX Frequency formula

Hybrid View

  1. #1
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    1,010

    Can you add a condition to a MAX Frequency formula

    Can you add a condition to a Max frequency formula or do the rows have to be consecutive for it to work please? I'm suspecting the latter.

    I've got this array formula that works

    =MAX(FREQUENCY(IF(ALL!$J$2:$J$5400="W",ROW(ALL!$J$2:$J$5400)),IF(ALL!$J$2:$J$5400<>"W",ROW(ALL!$J$2:$J$5400))))

    then I added a further condition and it doesn't, well at least not with the correct result..

    =MAX(FREQUENCY(IF(ALL!$E$2:$E$5400="H",ALL!$J$2:$J$5400="W",ROW(ALL!$J$2:$J$5400)),IF(ALL!$J$2:$J$5400<>"W",ROW(ALL!$J$2:$J$5400))))
    Last edited by Marvo; 12-03-2020 at 10:36 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,220

    Re: Can you add a condition to a MAX Frequency formula

    I think you have missed an IF clause - one If clause per condition.

    There are instructions at the top of the page explaining how to attach your sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

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

    Re: Can you add a condition to a MAX Frequency formula

    TRY
    =MAX(FREQUENCY(IF((All!$E$2:$E$5400="H")*(All!$J$2:$J$5400="W"),ROW(All!$J$2:$J$5400)),IF((All!$J$2:$J$5400<>"W")+(All!$J$2:$J$5400<>"H"),ROW(All!$J$2:$J$5400))))
    Formula: copy to clipboard
    =MAX(FREQUENCY(IF((All!$E$2:$E$5400="H")*(All!$J$2:$J$5400="W"),ROW(All!$J$2:$J$5400)),IF((All!$J$2:$J$5400<>"W")+(All!$J$2:$J$5400<>"H"),ROW(All!$J$2:$J$5400))))
    Samba

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

  4. #4
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    1,010

    Re: Can you add a condition to a MAX Frequency formula

    Hi, I've added a cut down version of my workbook. The working I showed is in cells J91, J92 & J93. The formula produced by samba-ravi is in K91, K92, K93 which produces a incorrect result of 1. The correct result (worked out manually) is in C91, C92 & C93. Many thanks for taking an interest.
    Attached Files Attached Files

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2505 (Windows 11 Home 24H2 64-bit)
    Posts
    91,220

    Re: Can you add a condition to a MAX Frequency formula

    Can you explain what it is that you are trying to work out with the formula?

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: Can you add a condition to a MAX Frequency formula

    Please try

    Home WINS
    =MAX(FREQUENCY(IF(ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400="W",ROW(ALL!$J$2:$J$5400))),IF(ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400<>"W",ROW(ALL!$J$2:$J$5400)))))

    Home DRAWS
    =MAX(FREQUENCY(IF(ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400="D",ROW(ALL!$J$2:$J$5400))),IF(ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400<>"D",ROW(ALL!$J$2:$J$5400)))))

    Home DEFEATS

    =MAX(FREQUENCY(IF(ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400="L",ROW(ALL!$J$2:$J$5400))),IF(ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400<>"L",ROW(ALL!$J$2:$J$5400)))))
    Attached Files Attached Files

  7. #7
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    1,010

    Re: Can you add a condition to a MAX Frequency formula

    Quote Originally Posted by Bo_Ry View Post
    Please try

    Home WINS
    =MAX(FREQUENCY(IF(ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400="W",ROW(ALL!$J$2:$J$5400))),IF(ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400<>"W",ROW(ALL!$J$2:$J$5400)))))

    Home DRAWS
    =MAX(FREQUENCY(IF(ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400="D",ROW(ALL!$J$2:$J$5400))),IF(ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400<>"D",ROW(ALL!$J$2:$J$5400)))))

    Home DEFEATS

    =MAX(FREQUENCY(IF(ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400="L",ROW(ALL!$J$2:$J$5400))),IF(ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400<>"L",ROW(ALL!$J$2:$J$5400)))))
    That works a treat. Thank you so much. I'm now going to try and learn how this works in order to finish the workbook. I'm very grateful.

  8. #8
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    1,010

    Re: Can you add a condition to a MAX Frequency formula

    Of course. The array formulas in C81 to C90 work out consecutive runs of wins, draws and losses, goals scored, conceded of football matches throughout the history of Northampton Town FC. They work fine.
    I'm now trying to add the condition of looking at matches played at HOME. I think I could do it with a separate sheet easily enough but if I can do it with a formula that would be preferable.

    I'll next be looking to add AWAY matches, then further down the line just league matches (non-cup)

  9. #9
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    1,010

    Re: Can you add a condition to a MAX Frequency formula

    Sorry, I've managed to get a lot further with this, changing the "H" to "A" and then "H" to "League" but need to put them together to add a final condition and am struggling. I've ended up with this

    =MAX(FREQUENCY(IF(ALL!$I$2:$I$5400="League",ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400="W",ROW(ALL!$J$2:$J$5400))),IF(ALL!$I$2:$I$5400="League",ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400<>"W",ROW(ALL!$J$2:$J$5400)))))

    I'm thinking where I add the "league" to the "H" is wrong in the initial IF condition?

    What I am asking is, If the match is a league match and if the match was played at home, then what is the most consecutive wins.

  10. #10
    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: Can you add a condition to a MAX Frequency formula

    Given that you have moved on with this, is the attchment still relevant, or do we need to see an updated version?
    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

  11. #11
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    1,010

    Re: Can you add a condition to a MAX Frequency formula

    Sorry Glenn, I've added the updated attachment. It's column C on the summary page. I've got down to C123 where I've hot the stumbling block adding the further condition. The correct result is shown in M123 which I did by manual inspection.
    Attached Files Attached Files

  12. #12
    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: Can you add a condition to a MAX Frequency formula

    OK!

    =MAX(FREQUENCY(IF(ALL!$I$2:$I$5400="League",IF(ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400="W",ROW(ALL!$J$2:$J$5400)))),IF(ALL!$I$2:$I$5400="League",IF(ALL!$E$2:$E$5400="H",IF(ALL!$J$2:$J$5400<>"W",ROW(ALL!$J$2:$J$5400))))))

    Try that. It's OK for C123. I'll try a couple of others....

  13. #13
    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: Can you add a condition to a MAX Frequency formula

    It fixes C125, as well...

  14. #14
    Forum Contributor Marvo's Avatar
    Join Date
    01-15-2009
    Location
    Northampton, England
    MS-Off Ver
    Excel 2021
    Posts
    1,010

    Re: Can you add a condition to a MAX Frequency formula

    Thanks Glenn, much appreciated. I should be able to finish it from here.

  15. #15
    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: Can you add a condition to a MAX Frequency formula

    Grand job! 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. SUM, IF, FREQUENCY formula count instances of sick time off [shorter formula?]
    By paulanderson in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-06-2020, 05:01 PM
  2. [SOLVED] Function FREQUENCY with condition
    By Eric Eric in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-26-2019, 04:57 AM
  3. Replies: 3
    Last Post: 01-21-2016, 02:23 PM
  4. [SOLVED] SUM FREQUENCY formula to count distinct values w/ OR condition
    By HeyInKy in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-05-2015, 03:55 PM
  5. Replies: 3
    Last Post: 02-11-2014, 05:36 PM
  6. [SOLVED] Help for if condition formula result only either hit or miss from mulitple condition
    By breadwinner in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-09-2013, 07:29 AM
  7. Replies: 8
    Last Post: 08-19-2010, 05:41 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