+ Reply to Thread
Results 1 to 54 of 54

Using MOD and IF to find cell value vs reference and show if divisible but I have an issue

  1. #1
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Arrow Using MOD and IF to find cell value vs reference and show if divisible but I have an issue

    What I'm trying to do here is review weights, week by week. If a player loses weight for the third week (across any date range) then consider that a "Hat Trick". Hat Tricks can only be scored on the week they are achieved.

    So, as you'll see from the example, the weights are added in weekly, and the formula I'm using shows correctly whether the range of cells showing as "losing weight" is divisible by 3 (i.e. denoting a hat trick), however when the next week is added, if the player has NOT lost weight, the formula still thinks that a hat trick is due. I know I need to include the date somehow but I'm stumped.

    Can you help?

    sample_ceepeebee.xlsx

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

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Another approach entirely (assuming your VERSION of O365 is reasonably up to date):

    =LET(A,H6:V6,B,TAKE(FILTER(A,A<>""),,-3),IF(AND(INDEX(B,,1)>INDEX(B,,2),INDEX(B,,2)>INDEX(B,,3)),"Hat Trick",""))
    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.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  3. #3
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Hi Glenn,

    Thanks for the reply. I won't lie - I had to use the evaluate function to figure out what this was doing

    It isn't quite what I need I don't think though. From what I can see, it's looking across the entire date range where weights might be entered, indexing the last 3 entries and comparing them to see if they meet criteria (which, I haven't fully understood yet in your formula if I'm honest), and then deciding whether it constitutes a hat-trick or not.

    Where it falls down is that a hat-trick is defined as such: "3 weeks of weight loss, at any point (not necessarily consecutive)".

    Therefore, if they lost weight, week 1, 2 and 3, week 4 wouldn't be a hat-trick. Only when the next batch of 3 weight losses occur would another hat-trick be issued. The image below shows that this would indeed be a hat-trick. In addition, say 5 weeks have passed, and Wk 1, and 2 were weight losses, then 3 and 4 were static, and 5 was a weight loss, this would be a hat-trick, but them losing weight again in week 6 would NOT be, as the counter resets after the ha-trick (hope this makes sense)

    Attachment 825909

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

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Your understanding of my formula is spot on.



    Please upload an Excel file witha RANGE of scenarios and expected outcomes. Not just one.

  5. #5
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Thanks Glenn - here's a sample showing the 2 main areas, and the 1 main issue. An individual can only be considered to have a hat trick on the 3rd week of weight loss (consecutively or otherwise), at the point of data entry. Currently, my formula will continue to show an individual as achieving a "hat trick" if they have lost a total of 3 times, and then never again (which is incorrect).

    See sample

    newsample_ceepeebee.xlsx

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    So a hattrick is not consecutive weeks of weight loss? It's simply every third week of weight loss, but only shows as such if this is the third week in succession - is this correct?
    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  7. #7
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Not quite. A hat-trick is purely every 3 weeks of weight loss, be they consecutive or not. The key is that once that hat-trick has been achieved, you start again building up those 3 weeks of weight loss over whatever future period.
    Last edited by AliGW; 04-16-2023 at 06:16 AM. Reason: Please do NOT quote unnecessarily!

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    That's what I meant.

    Try this:

    =AND(SUMPRODUCT(($I6:$V6<$H6:$U6)*($H6:$U6<$C6))>0,MOD(SUMPRODUCT(($I6:$V6<$H6:$U6)*($H6:$U6<$C6)),3)=0,LOOKUP(2,1/($H6:$V6<>0),$H6:$V6)<LOOKUP(2,1/($H6:$V6<>0),$G6:$U6))
    Attached Files Attached Files

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Can be shortened to:

    =LET(a,SUMPRODUCT(($I6:$V6<$H6:$U6)*($H6:$U6<$C6)),AND(a>0,MOD(a,3)=0,LOOKUP(2,1/($H6:$V6<>0),$H6:$V6)<LOOKUP(2,1/($H6:$V6<>0),$G6:$U6)))
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    can you please explain the formula for my understanding too? thanks - I'll try it

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Not until you've tested it - I don't want to waste time explaining something that doesn't work! Add more data and see if it continues to give the results you want, then let me know and I'll explian it.

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    OK, well just in case you have already tested it, here's an explanation:

    Please Login or Register  to view this content.
    SUMPRODUCT(($I6:$V6<$H6:$U6)*($H6:$U6<$C6)

    This compares all cells in the range and checks that (a) any cell is SMALLER than the one before it and (b) any cell is less than the starting weight in C6.

    AND(a>0

    Checks that the SUMPRODUCT formula returns a value more than 0 ...

    MOD(a,3)=0

    ... and that the MOD of that formula equals 0 (i.e. divisible by 3 exactly for the hattrick) ...

    LOOKUP(2,1/($H6:$V6<>0),$H6:$V6)

    ... and that the very last entry in the range ...

    <LOOKUP(2,1/($H6:$V6<>0),$G6:$U6)))

    ... is less then the penultimate value in the range.

    If all THREE criteria are met, the formula returns TRUE.

  13. #13
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    So, after testing, this seems to do exactly what I'm after. Effectively "resetting the count" after each successful 3rd weight loss. Many thanks. I await your response. (I'll try and work it out anyway :D )
    Last edited by AliGW; 04-16-2023 at 06:47 AM. Reason: Please do NOT quote unnecessarily!

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    See post #12 above yours. Use EVALUATE FORMULA on the FORMULAS ribbon to step through the formula to see what it's doing.

    Administrative Note:

    Please don't quote whole posts, especially when you are responding to the one immediately preceding your own - it's just clutter and rarely necessary.

    If you are responding out of sequence, it is usually enough just to mention the helper's user name (e.g @AliGW).

    If you do need to quote, limit the quoted section just to the section to which you wish to draw your helper's attention or a direct question to which you wish to respond.

    For normal conversational replies, try using the QUICK REPLY box below or the REPLY button instead of REPLY WITH QUOTE.

  15. #15
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Thanks AliGW

    The only bit I do not understand is why there is a reference to $G6 in there (i.e. the formula cell)? The sample I gave you is a paired down version of the full sheet I'm developing, and there are many more columns between the formula/hat-trick cell, and the weight entries, so I just want to be sure what I'm referencing and why.

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Your ranges have to be equal in length for it to work. It doesn't matter what is in that cell - it just needs to be the one immediately prior to the range of weight entries. You don't need to worry, as nobody is going to score a hattrick with the entry in H6, so it's not going to throw an error, but if it does at the start, then just wrap the whole thing in an IFERROR function.

    Glad to have helped.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  17. #17
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Okay, I'm just sanity checking a few areas before I mark as solved - thanks so much so far! :D

  18. #18
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    No worries at all - when you come to apply it, if there are issues, just shout here.

  19. #19
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    I've come across a little issue when I try and put this into production.

    I obviously remove all of the dates and entries, and start to enter a new set of weights for "week 1". It's at that point my Hat-trick gives a circular reference to my score totaling cell. See the example. I cannot for the life of me figure out how to ensure that week 1 works correctly. After week 1, it rights itself again.

    Equally, my "weekly result" cell (F15) is playing up as it's the first week too. I tried changing the position of the C15 cell in the formula but I think it needs more nuance than that. I'll take another look tomorrow when it's not 11pm, but I know I'll struggle with the Hat Trick one

    Is there any chance you might take a look and see what I mean? For the circular reference, once I move on to later dates, it rights itself for some weeks but not others.

    circular.jpg

    example_cpb.xlsx
    Last edited by ceepeebee; 05-09-2023 at 10:03 AM. Reason: updated description

  20. #20
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Any ideas guys? I have to use this in production this weekend - I'm lost currently. Thanks in advance for any assistance.

  21. #21
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Try either this:

    =IF(COUNT($S15:$AG15)<2,FALSE,(IF($C15="","",LET(a,SUMPRODUCT(($T15:$AG15<$S15:$AF15)*($S15:$AF15<$C15)),AND(a>0,MOD(a,3)=0,LOOKUP(2,1/($S15:$AG15<>0),$S15:$AG15)<LOOKUP(2,1/($S15:$AG15<>0),$R15:$AF15))))))

    or this:

    =IF(COUNT($S15:$AG15)<2,"",(IF($C15="","",LET(a,SUMPRODUCT(($T15:$AG15<$S15:$AF15)*($S15:$AF15<$C15)),AND(a>0,MOD(a,3)=0,LOOKUP(2,1/($S15:$AG15<>0),$S15:$AG15)<LOOKUP(2,1/($S15:$AG15<>0),$R15:$AF15))))))

    It works correctly as soon as you have more than one number in the range.
    Attached Files Attached Files

  22. #22
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Thanks Ali - The resolution of the circular reference means at least that the rest of my calculated fields work off the back of it. thanks again.

    I'm still struggling with the weekly result cell not showing as I want it to, but I haven't posted separately about that

  23. #23
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    The weekly result is a different issue - please start a new thread for that with a suitable title and workbook attached.

  24. #24
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Hello again Ali - it seems I've hit a snag as we've moved through the weeks, that I am unable to resolve. See attached.

    Essentially, some players have hit a "hat-trick" and the formula has ceased to agree. The formula seems to mirror the original one that was marked as resolved. I have looked through as best I can but I am unable to determine the cause.


    Any assistance would be greatly appreciated.

    Copy of FVF Weight Tracker 2023 (1) test.xlsx

  25. #25
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    The first weight in the so-called hat-trick is NOT below 129, so it doesn't count (based on what you told me before), so there is no hat-trick. Change V6 to 128, and the hat-trick will be valid.

    If your rules have changed, then the formula will need to be changed. At the moment, that first value of the three does not pass muster.
    Last edited by AliGW; 06-19-2023 at 03:58 AM.

  26. #26
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Looking at your CF rules, I think they are inaccurate based on the rules you explained earlier in the thread. Green should only kick in when weights drop below the starting weight, e.g =AND(T6<$C6,T6<S6).

    Amber would need to be: =OR(T6=S6,T6>=$C6).

    I've updated the workbook so that the CF matches your rules (as I understand them) better.
    Last edited by AliGW; 06-19-2023 at 04:25 AM. Reason: Workbook added.

  27. #27
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Hello Ali,

    Thanks for your response. As I explained in the earlier thread, a hat-trick is just 3 weeks of weight loss. The start weight is only used to determine whether their week 1/first weigh in is a loss or otherwise. From this point, all weight calculations are based on the preceding week's weight value, and [B]not[B] their starting weight.
    Last edited by ceepeebee; 06-19-2023 at 04:43 AM.

  28. #28
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    So why didn't you say that when I explained this:

    This compares all cells in the range and checks that (a) any cell is SMALLER than the one before it and (b) any cell is less than the starting weight in C6.
    This means that the formula is incorrect after all. I will have a rethink.

  29. #29
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Try this instead:

    =IF(COUNT($S6:$AG6)<2,FALSE,(IF($C6="","",LET(a,SUMPRODUCT(($T6:$AG6<$S6:$AF6)*($T6:$AG6<>"")),AND(a>0,MOD(a,3)=0,LOOKUP(2,1/($S6:$AG6<>0),$S6:$AG6)<LOOKUP(2,1/($S6:$AG6<>0),$R6:$AF6))))))

  30. #30
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Hi Ali,

    I really appreciate your assistance here, but your adversarial response, less so. I simply missed your point about the starting weight. My apologies.
    Last edited by AliGW; 06-19-2023 at 04:58 AM. Reason: Please do NOT quote unnecessarily!

  31. #31
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Not adversarial at all - just wondering why you didn't challenge it, as I thought you'd understood the explanation of what I had done.

    I clearly misinterpreted the requirement in that one respect.

    I am entitled to ask questions when I am giving so freely and generously of my own time!

    I hope this has fixed the issue, as I am now going to move on. Please remark the thread as solved, if so. If not, then explain in detail what is not working and in what way.
    Last edited by AliGW; 06-19-2023 at 05:06 AM.

  32. #32
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Hi Ali,

    I have reviewed your sample workbook, and unfortunately, it seems to still be giving me an incorrect response by counting a 4th weight loss as a hat-trick.

    Let me just re-confirm the rules here: First, the value in $C is their starting weight. That is used purely to determine whether their first weigh in (in $S) is a weight loss/gain etc. From that point on, all we are looking at is whether the current weigh in date value is a gain or loss compared to the previous week. Once 3 losses are recorded (throughout whatever period) this is considered a hat-trick. For example, week 1 and 2 could be gains, week 3 could be a loss, week 4 stayed the same, and week 5 and 6 are losses - this would be a hat-trick.

    The weigh in immediately post the hat-trick starts the cycle again. So a 4th loss is no longer a hat-trick and is instead "1 loss", and the cycle continues until 3 losses are hit. All of this looks at the previous weigh in value though, [B]not[B] the starting weight.


    Essentially, it is now looking

    See attached.

    Copy of FVF_Sample.xlsx

  33. #33
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    OK - at this point, I'm going to declare myself out.

    You need to supply a sample dataset with 20-30 lines of data that can be used by someone helping you for testing purposes - a set that will cover all eventualities that you can possibly think of. Providing one row of data is not enough, I am afraid, no matter how many times you repeat the rules.

    I confess to not feeling secure in my understanding any longer - what you are describing seems to be a long way away from what I would consider a hat-trick.

    Hopefully someone else will get a better grasp on it. Good luck.
    Last edited by AliGW; 06-19-2023 at 05:39 AM. Reason: Typo fixed.

  34. #34
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Thanks Ali

    I understand. I have samples here with all my data in, but wanted to use one line to more accurately detail the areas that are incorrect.

    I would highlight my requirement has not changed from day one, but I fully appreciate you fiving your time free and generously.

  35. #35
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    I understand that your requirement hasn't changed - I never said it had. My understanding of it has changed, though, and I don't feel confident enough to move forward on this.

    but wanted to use one line to more accurately detail the areas that are incorrect.
    But you see that could go on forever!!! If you are only going to provide data that really will only identify one potential issue at a time, it means that there will need to be many tweaks to the formula over time, and that becomes frustrating for helpers who are trying to fully understand what you need and for you when, necessarily, they have to ask questions. And please be clear on this: helpers WILL expect you to have read everything carefully and picked up on any mistakes in their understanding: that is as much your responsibility as it is theirs. It's really important that you check everything really carefully. I am not blaming you: I misinterpreted the brief, but I was surprised that you had missed something crucial when I had taken the time to explain in quite some detail what my formula was doing. I hope this all makes sense and that you don't take it personally.

    To be clear: I thought that my formula (the one given today) fully met the brief - I couldn't find anything in my re-reading of your posts that suggested that it did not. So it's not just us not understanding it, it's your not fully demonstrating it as well. It works both ways.

    What you need is exemplar data that is detailed snough to cover all eventualuities that you can think of. Then whoever helps has a much better chance of hitting the jackpot at their first attempt. Please provide that now.

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

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    I'm more than happy to take another look.

    But. I am:

    a) not willing to read through 35 previous posts to understand fully;

    b) not prepared to make further guesses when there is ONLY one sample made available..

    Please restate your ENTIRE requirement and upload a sample with about 10 rows of data that cover ALL possible scenarios AND which contain expected results in ALL cases.

  37. #37
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Appreciate it Glenn,

    The one remaining item on the "fix list" for this sheet is to ensure that a cell correctly determines whether or not an individual has achieved a "hat trick" of weight losses. As you'll see from the sample, each individual has a row dedicated to capturing various information for them. The key cells for this issue is as follows:
    • $C
    • $S to $AG
    • $K - where the formula that compares the above cells, sits

    There are a number of rules that govern what should happen here. In natural language, what we're doing is weighing an individual when they join the club and noting their "start weight" (Column C). Each time they attend we weigh them again and note them accordingly in the relevant dated column (S onwards). The formula in column K has to calculate the following:
    • If this is a fresh sheet (read new season), is their first weigh in (14/05/2023 on the sample) higher, equal or lower than their starting weight in C
    • In subsequent weeks (i.e. week 2 onwards) is their weigh in higher, equal or lower than their previous week
    • Taking the above into account, have they achieved a Hat-Trick.

    A hat-trick is defined as ANY 3 entries of weight loss, at any point. So, to cover the rules here, consider 5 weeks of weigh ins spanning column S to W.
    • If a player has stayed the same as their starting weight week 1, lost weight compared to their week 1 weight in week 2, repeated that in week 3 (compared to week 2), put weight on in weeks 3 and 4, but lost weight in week 5 (again, compared to week 4), this would be considered a hat-trick
    • If a player has consistently lost weight for all 5 weeks, this is NOT a hat-trick, albeit they are one more 'loss' at some point in the future away from a hat-trick.

    The key is for the product of the losses to always be divisible by 3 (3 weight losses) to be considered a hat-trick.

    Hopefully this makes sense and thanks again for taking a look.

    FVF_Sample.xlsx

  38. #38
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Please highlight the rows where the formula is NOT producing the result you want.

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

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    You did NOT include expected answers... I asked for these in ALL cases.

    This is probably incorrect, as I suspect Stefan Atkins should be a "". Please ADD expected answers. My confusion arises over whether the HT result should apply to ONLY the current week...

    I put the formula in column M to compare with the expected answers that I had expected to see in column K.
    Attached Files Attached Files

  40. #40
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Quote Originally Posted by Glenn Kennedy View Post
    You did NOT include expected answers... I asked for these in ALL cases.

    This is probably incorrect, as I suspect Stefan Atkins should be a "". Please ADD expected answers. My confusion arises over whether the HT result should apply to ONLY the current week...

    I put the formula in column M to compare with the expected answers that I had expected to see in column K.
    Hi Glenn,

    Apologies. I just wrote a massive response, but then my browser crashed, so bear with me!

    To answer your last piece first, yes, Stefan would not have a TRUE value in K31 for relating to the newly entered value in X31, regardless of if it was a weight loss or not, as he has already achieved a hat-trick and has now started the count to 3 again.

    As an example of expected answers, let's take row 34, Tom, in my original sample attachment. The rules are relatively static as is the process.

    First example: I come to weigh an individual, I change the cell value of B2 to the current date, which will correspond with the date, in this case, in Y13 (I'll change it to the 25/06/2023). I enter the weight of Tom, and enter it into Y34. At this point, one of 3 things is going to happen.
    • The value of Y34 is higher than X34. Conditional formatting changes it to RED, and the value in K34 remains FALSE as there has been no weight loss according to this value.
    • The value of Y34 is equal to that of X34. Conditional formatting changes it to AMBER/YELLOW, and the value in K34 remains FALSE as there has been no weight loss according to this value.
    • The value of Y34 is LESS than that of X34. Conditional formatting changes it to GREEN, and the value in K34 changes to TRUE. This is to reflect Tom's other losses in S34 and T34.

    Second example: Let's fast forward to the following week. I change B2 to be 02/07/2023, and weigh Tom once more.
    • The value of Z34 is higher than Y34. Conditional formatting changes it to RED, and the value in K34 remains FALSE as there has been no weight loss according to this value.
    • The value of Z34 is equal to that of Y34. Conditional formatting changes it to AMBER/YELLOW, and the value in K34 remains FALSE as there has been no weight loss according to this value.
    • The value of Z34 is LESS than that of Y34. Conditional formatting changes it to GREEN, and the value in K34 remains FALSE as whilst there is weight loss, the weight losses so far amount to 4 (S34, T34, Y34 and now Z34). He had his Hat-Trick last week and he has started a new journey towards a new Hat-Trick (i.e. the next 3 weight losses). Essentially the SUM of the weight losses in the range are not divisible by 3

    Third example: Let's rewind to 28/05/2023. Tom has a value ofB2 value is set as the 28/05/2023, and Tom has had 2 previous weight losses in S34 and T34. We enter a new value in U34.
    • The value of U34 is higher than T34. Conditional formatting changes it to RED, and the value in K34 remains FALSE as there has been no weight loss according to this value.
    • The value of U34 is equal to that of T34. Conditional formatting changes it to AMBER/YELLOW, and the value in K34 remains FALSE as there has been no weight loss according to this value.
    • The value of U34 is LESS than that of T34. Conditional formatting changes it to GREEN, and the value in K34 changes to TRUE. This is to reflect Tom's other losses in S34 and T34.

    The key here is for K34 to not only take into account values from T34 onwards and comparing them to the previous cell in the row (i.e.iIs T34 >, <, = to S34) but to also compare S34 with C34 for that first weigh in week.

  41. #41
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    You need to ADD a column to the workbook with your EXPECTED results filled in manually. Please do this NOW.

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

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    STILL no expected answers... My last guess without expected answers:

    =LET(A,S15:AG15,B,FILTER(A,A<>0),C,--(DROP(B,,1)-DROP(B,,-1)<0),IFERROR(IF(AND(MOD(SUMPRODUCT(--(C=1)),3)=0,SUM(C)>0,SUM(TAKE(B,,-2)*{-1,1})<0),"HT",""),""))
    Attached Files Attached Files

  43. #43
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Quote Originally Posted by AliGW View Post
    You need to ADD a column to the workbook with your EXPECTED results filled in manually. Please do this NOW.
    It is not that simple as the expected answers changed based on the date in cell value B2 as I've mentioned numerous times now. I can look at the static data in Glenn's example (and I have now updated this as required).

    Quote Originally Posted by Glenn Kennedy View Post
    STILL no expected answers... My last guess without expected answers:

    =LET(A,S15:AG15,B,FILTER(A,A<>0),C,--(DROP(B,,1)-DROP(B,,-1)<0),IFERROR(IF(AND(MOD(SUMPRODUCT(--(C=1)),3)=0,SUM(C)>0,SUM(TAKE(B,,-2)*{-1,1})<0),"HT",""),""))
    Glenn, I've updated your sample with a column detailing where the expected answers differ from the ones your formula derives. I hope this is what you are expected, but as above, the dynamic aspect here is the value in B2, which will change each week and as such will change the starting point (or ending point) for the calculation I would imagine?

    FVF_Sample (1)_CB.xlsx

  44. #44
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    It is not that simple as the expected answers changed based on the date in cell value B2
    You give expected answers based on the date value that is currently in B2. It is perfectly simple, as I have been saying since the start of this thread.

    Please explain WHY row 32 should be FALSE.

    EDIT: Forget that - I've just noticed yo uadded a comment.
    Last edited by AliGW; 06-20-2023 at 05:09 AM.

  45. #45
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Quote Originally Posted by AliGW View Post
    You give expected answers based on the date value that is currently in B2. It is perfectly simple, as I have been saying since the start of this thread.

    Please explain WHY row 32 should be FALSE.
    I did - I added a comment.

  46. #46
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Yes, I had just edited my last post - I didn't know I was looking for a comment attached to the cell. I was expecting something in a worksheet cell wo it could be seen without having to hover over a cell!

  47. #47
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    You really don't have to assist Ali if I'm proving to be such a difficult forum user - feel free to help those that can talk to you on the same level.

  48. #48
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Oh, for goodness sake! Don't be so silly. Of course I want to help - I wouldn't keep trying otherwise.

    Try this in K15 copied down:

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by AliGW; 06-20-2023 at 06:02 AM. Reason: Workbook added.

  49. #49
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    That actually seems to resolve it Ali. Let me throw it in my production sheet.

    Could you give an overview of why this is different and what it's doing please?

  50. #50
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    I'll do my best!

    =LET(c,SUM(T15<C15),

    Checks if T15 is lower than C15 and returns 1 if it is - this is NEW.

    a,SUMPRODUCT((U15:AH15<>"")*(U15:AH15<T15:AG15)),

    Counts the number of times there is a weight loss for cells that are not blank.

    b,LOOKUP(2,1/((T15:AH15<>0)),T15:AH15)<LOOKUP(2,1/((T15:AH15<>0)),S15:AG15),

    Checks that the last value in the range is less than the penultimate value.

    IFNA(IF(AND(a>0,b=TRUE,MOD(c+a,3)=0),"HT",""),""))

    Checks that (a) there are weight losses in the range, (b) that the final value IS lower than the penultimate value, (c+a) adds c to a (this is NEW and makes sure that the first cell is included in the count if it is a weight loss).

    Then the MOD kicks in and checks that the count meets that criterion.

    Phew!!!

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  51. #51
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    So did it work?

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

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

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    OK. Second place to Ali... an alternative:

    =LET(A,HSTACK(C15,T15:AH15),B,FILTER(A,A<>0),C,--(DROP(B,,1)-DROP(B,,-1)<0),IFERROR(IF(AND(MOD(SUMPRODUCT(--(C=1)),3)=0,SUM(C)>0,SUM(TAKE(B,,-2)*{-1,1})<0),"HT",""),""))
    Attached Files Attached Files

  53. #53
    Registered User
    Join Date
    04-15-2023
    Location
    Midlands, UK
    MS-Off Ver
    365
    Posts
    25

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Haven't tried Glenn's alternative yet, but yes Ali, it seems to have worked. I'll close as resolved.

  54. #54
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,916

    Re: Using MOD and IF to find cell value vs reference and show if divisible but I have an i

    Good show!

+ 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: 0
    Last Post: 12-11-2020, 05:18 AM
  2. Find nearest divisible value from a list to a specified value
    By Geoffreym in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 08-14-2020, 11:45 AM
  3. formula: If cell is divisible by 10, then TRUE.. how to set it up?
    By cat3appr in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 05-10-2019, 11:37 AM
  4. [SOLVED] conditional formatting based on a divisible factor minus 1 and age populated by bday issue
    By TravisD76 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-29-2019, 01:35 AM
  5. Replies: 4
    Last Post: 09-10-2016, 06:56 AM
  6. [SOLVED] If not divisible, find a divislbe number
    By olemgaa in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 09-04-2015, 05:51 AM
  7. [SOLVED] Show only numbers divisible to one
    By Armannn in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-22-2014, 11:56 PM

Tags for this Thread

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