+ Reply to Thread
Results 1 to 19 of 19

Logic Updates to existing formulas (duplicates, exclusion, lookups)

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Logic Updates to existing formulas (duplicates, exclusion, lookups)

    See the attached workbook:

    I am requesting assistance with a few different updates to existing logic, which I will explain.

    Update 1:

    Two logic updates to Column Q:
    - update to avoid counting duplicate values
    - exclude counting when 'rej' is listed in description:

    In the 'SHIP' tab:
    When Column A has the same value, Column D = "Final" and Column I = "C D w/ I"
    Column Q aggregates the values in Column E

    Is there a way to update this formula to avoid counting duplicate values in Column Q?

    I listed two example: 1163603 and 1172600 with the expected value at the end of each row.

    Also, for the Column Q logic update, do not include those rows that have the word "Rej" within Column K. If "Rej" is found within the description, do not include any values in Column E in the calculation.

    Example: 1179778


    Update 2 :
    In the 'Pre' Tab:

    Column U is currently performing a calculation based on the data from Column T.
    How would this formula be updated to include two additional piece of logic.

    First logic update:
    If Column E = "AAA" or "BB OF B" then output "PRE CALC" IN Column T else perform the calculation.

    I have the values needed for this check in the tab called "Look" as I would prefer this to be a look-up in the formula.

    See examples: 1226572 and 1226191 in the attached workbook for this example.

    Second logic update:
    When Column T has a value of 1, do not peform the calculation; output '-' instead of the calculated value.

    See Example: 1224113 in the attached workbook for this example.
    Attached Files Attached Files

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

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    Please try

    Update 1:
    =AVERAGEIFS($E$2:$E$14,$A$2:$A$14,A2,$D$2:$D$14,"Final",$I$2:$I$14,"C D w/ I",$K$2:$K$14,"<>*rej*")

    or
    =SUM(IF(FREQUENCY(IF($A$2:$A$14=A2,IF($D$2:$D$14="Final",IF($I$2:$I$14="C D w/ I",IF(ISERROR(SEARCH("Rej",$K$2:$K$14)),$E$2:$E$14)))),--$E$2:$E$14),$E$2:$E$14))

    Update 2:
    =IF(ISNA(MATCH(E3,{"AAA";"BB of B"},)),IF(T3=1,"-",T3*25%%%),"Pre Calc")
    Attached Files Attached Files

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

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    You didn't even try my 2nd formula

    or
    =SUM(IF(FREQUENCY(IF($A$2:$A$14=A2,IF($D$2:$D$14="Final",IF($I$2:$I$14="C D w/ I",IF(ISERROR(SEARCH("Rej",$K$2:$K$14)),$E$2:$E$14)))),--$E$2:$E$14),$E$2:$E$14))

    Quote Originally Posted by Bo_Ry View Post
    Please try
    Update 1:
    =AVERAGEIFS($E$2:$E$14,$A$2:$A$14,A2,$D$2:$D$14,"Final",$I$2:$I$14,"C D w/ I",$K$2:$K$14,"<>*rej*")

    or
    =SUM(IF(FREQUENCY(IF($A$2:$A$14=A2,IF($D$2:$D$14="Final",IF($I$2:$I$14="C D w/ I",IF(ISERROR(SEARCH("Rej",$K$2:$K$14)),$E$2:$E$14)))),--$E$2:$E$14),$E$2:$E$14))
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    Quote Originally Posted by Bo_Ry View Post
    You didn't even try my 2nd formula
    Hello,

    I did try your 2nd formula. For ID 1163603, it calculates a value of 473,870,642. I am expecting that value to be 302,404,597 because there is a duplicate value in Column E for that ID (based on Column A).

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

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    Quote Originally Posted by bdav1216 View Post
    Hello,

    I did try your 2nd formula. For ID 1163603, it calculates a value of 473,870,642. I am expecting that value to be 302,404,597 because there is a duplicate value in Column E for that ID (based on Column A).
    File from Post# ID 1163603 looks like 302,404,597 to me

    2021-02-21 23_04_18-SampleP.xlsx - Excel.png

  6. #6
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    Quote Originally Posted by Bo_Ry View Post
    File from Post# ID 1163603 looks like 302,404,597 to me
    Yes, this formula is looking good upon my initial review:

    =SUM(IF(FREQUENCY(IF($A$2:$A$14=A2,IF($D$2:$D$14="Final",IF($I$2:$I$14="C D w/ I",IF(ISERROR(SEARCH("Rej",$K$2:$K$14)),$E$2:$E$14)))),--$E$2:$E$14),$E$2:$E$14))

    For the 'PRE' tab, how would that formula be updated to output a "-" when the calculation has a value of "VALUE!"? An example was: 1226191 where Columnt T
    is currently equal to '-', resulting in that 'VALUE'!" error?

    Existing formula:
    =IF(ISNA(MATCH(E3,{"AAA";"BB of B"},)),IF(T3=1,"-",T3*25%%%),"Pre Calc")
    Last edited by bdav1216; 02-21-2021 at 08:48 PM.

  7. #7
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    Quote Originally Posted by Bo_Ry View Post
    Please try

    =SUM(IF(FREQUENCY(IF($A$2:$A$14=A2,IF($D$2:$D$14="Final",IF($I$2:$I$14="C D w/ I",IF(ISERROR(SEARCH("Rej",$K$2:$K$14)),$E$2:$E$14)))),--$E$2:$E$14),$E$2:$E$14))
    One other question:

    For this formula:

    =SUM(IF(FREQUENCY(IF($A$2:$A$14=A2,IF($D$2:$D$14="Final",IF($I$2:$I$14="C D w/ I",IF(ISERROR(SEARCH("Rej",$K$2:$K$14)),$E$2:$E$14)))),--$E$2:$E$14),$E$2:$E$14))

    How would I remove the logic to check for "Rej"? The rest of the logic should stay the same.

  8. #8
    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: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    Average... of course!! nice lateral thinking, there...
    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

  9. #9
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    Thank you!

    The logic for Updates 2 are looking good!

    One update -> I do receive #VALUE! errors in some calculations. How would I update the formula you provided to address that?

    For Updates 1, using Average is causing issues because there could be different values (not always duplicated values). For example, if Column E has 10 and 10, the 10 for average makes sense, but if the values are 10 and 2, instead of calculating '12', it's calculating a value of 6.

    Is there a way to update this formula aggregate only the unqiue values (vs. taking the average)?

    Also, I am receiving a #DIV/0! error when there are no aggegrations possible for an ID. How would I update that formula to have a '-' present

    I can provide a few more examples.
    Last edited by bdav1216; 02-19-2021 at 11:23 AM.

  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: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    Do. There's not much point in telling us what we can't see...

  11. #11
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    Thank you!

    In the 'PRE' tab, I added one new example (ID: 1226191) where the updated formula is outputting a #VALUE!
    Can the exisiting formula be updated to output '-' instead of #VALUE!

    For the 'SHIP' tab:
    1154375 where current formula results in #DIV/0!
    Can the exisiting formula be updated to output '-' instead of #DIV/0!?

    1155626 and 1162502 are examples where there different values that should be aggregated, not an average. I understand why average works when you have the same values, but it doesn't work when you have different values. These examples will show different values and the expected result.
    Attached Files Attached Files

  12. #12
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    This is for update 1
    In Q2 then copied down.
    =IF(COUNTIFS($A$2:$A2,A2,$D$2:$D2,"Final",$I$2:$I2,"C D w/ I",$K$2:$K2,"<>*Rej*")=1,SUMIFS($E$2:$E$14,$A$2:$A$14,A2,$D$2:$D$14,"Final",$I$2:$I$14,"C D w/ I",$K$2:$K$14,"<>*Rej*"),"")
    Is this ok. Check for rows 11 and 12.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  13. #13
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    Quote Originally Posted by kvsrinivasamurthy View Post
    This is for update 1
    In Q2 then copied down.
    =IF(COUNTIFS($A$2:$A2,A2,$D$2:$D2,"Final",$I$2:$I2,"C D w/ I",$K$2:$K2,"<>*Rej*")=1,SUMIFS($E$2:$E$14,$A$2:$A$14,A2,$D$2:$D$14,"Final",$I$2:$I$14,"C D w/ I",$K$2:$K$14,"<>*Rej*"),"")
    Is this ok. Check for rows 11 and 12.
    Hello

    I did try your 2nd formula. For ID 1163603, it calculates a value of 473,870,642. I am expecting that value to be 302,404,597 because there is a duplicate value in Column E for that ID (based on Column A).

    ID: 1163603 has the same issue as 1172600.
    ID: 1172600 should output 50,039 (not 100,078) because both of the qualifiying rows have the same value (50,039). When this occurs (same values), I only want to aggregate one row. I should only aggregate when there are different values for qualifying rows. For example, if one value was 50,039 and the other was 10, then it should aggregate to 50,049
    ID: 1179778 is accurate
    ID: 1224113 is accurate
    ID: 1226191 is accurate
    ID: 1226572 is accurate

    Is there a way to account for these scenarios?

  14. #14
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    For both scenario's, I do also want to account for a default of '-' when there is no calculation available to avoid #VALUE or #DIV/0! also.

  15. #15
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    This is for update 1
    In Q2 then copied down

    =IF(COUNTIFS($A$2:$A2,A2,$D$2:$D2,"Final",$I$2:$I2,"C D w/ I",$K$2:$K2,"<>*Rej*")=1,SUMPRODUCT($E$2:$E$14*($A$2:$A$14=A2)*($D$2:$D$14="Final")*($I$2:$I$14="C D w/ I")*(ISERROR(SEARCH("*Rej*",$K$2:$K$14))))/SUMPRODUCT(($A$2:$A$14=A2)*($D$2:$D$14="Final")*($I$2:$I$14="C D w/ I")*(ISERROR(SEARCH("*Rej*",$K$2:$K$14)))),"")
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 02-21-2021 at 10:52 PM.

  16. #16
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    Quote Originally Posted by kvsrinivasamurthy View Post
    This is for update 1
    In Q2 then copied down
    Thank you, I will take a look at this shortly. I appreciate the help.

    If you're able to take a look at that 'PRE' tab question around the '-' default for the "VALUE!" issue, let me know. Thank you again!


    For the 'PRE' tab, how would that formula be updated to output a "-" when the calculation has a value of "VALUE!"? An example was: 1226191 where Columnt T
    is currently equal to '-', resulting in that 'VALUE'!" error?

    Existing formula:
    =IF(ISNA(MATCH(E3,{"AAA";"BB of B"},)),IF(T3=1,"-",T3*25%%%),"Pre Calc")

  17. #17
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    Not clear about explanation. On Guess, in " PRE" tab
    Formula in T3 then copied down
    =IF(OR($E3="AAA",$E3="BB of B"),"Pre calc",IFERROR(IF(AND(D3="Net Down",L3>0,ISNUMBER(P3),ISNUMBER(R3)),MAX(O3:P3)-R3,IF(L3<>0,MAX($O3:$P3)-$R3,"-")),"-"))
    Attached Files Attached Files

  18. #18
    Forum Contributor
    Join Date
    03-19-2016
    Location
    Chicago, IL
    MS-Off Ver
    Office 2016 Professional
    Posts
    388

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    Quote Originally Posted by kvsrinivasamurthy View Post
    Not clear about explanation. On Guess, in " PRE" tab
    Formula in T3 then copied down
    Thank for you taking a look.

    Let me clarify for you.

    In the attached examples on the 'PRE' tab, Column U is outputting a '#VALUE!' when Column T defaults to a '-'.

    I need the logic for Column U updated, not Column T, to also output a '-' when the calculation cannot be performed.

    ID: 1226191 is an example where Column T is ouptting a '-', but Column U is not able to be calcluated, resulting in the '#VALUE!' error.

    Current Logic in Column U:
    =IF(ISNA(MATCH(E4,{"AAA";"BB of B"},)),IF(T4=1,"-",T4*25%%%),"Pre Calc")

  19. #19
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Logic Updates to existing formulas (duplicates, exclusion, lookups)

    Formula in U3 is

    =IFERROR(IF(T3="-","-",T3*0.000025),"-")

    Not what you are showing in post#17

+ 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: 4
    Last Post: 12-11-2018, 12:53 PM
  2. lookups for duplicates
    By ermias in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-12-2018, 04:39 AM
  3. Deeper if then logic for existing fomula?
    By jriker1 in forum Excel General
    Replies: 4
    Last Post: 07-17-2017, 01:53 PM
  4. Need excel logic formula or macro that will do multiple lookups
    By ChristineF_Gtown in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-09-2014, 11:55 AM
  5. Updates and Modification to Existing Project
    By Pherion in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-28-2009, 01:11 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