+ Reply to Thread
Results 1 to 22 of 22

Outputting Values to New Column Based on ID and IF condition

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

    Outputting Values to New Column Based on ID and IF condition

    See the attached samples:

    When Column A (ID) has the same value -> Evalulate IF Column D (Type) = "FFFT" AND Column I (Delivery) = "ABC w/ I"

    When these values exist for the same Column A (ID), output the values of Column J (Relation) Into Column K (Expected Value).

    - If there are blank values in Column J, output '-'.
    - If there are more than one instance where Colume D (Type) = "FFFT" AND Column I (Delivery) = "ABC w/ I", output ALL values separated with a "/"
    - If there are no instances where Colume D (Type) = "FFFT" AND Column I (Delivery) = "ABC w/ I", output 'No Scenarios'
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Outputting Values to New Column Based on ID and IF condition

    Hi

    in k2 and down:
    Please Login or Register  to view this content.
    The formula will cover only 3 instances that are separated by "/"

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

    Re: Outputting Values to New Column Based on ID and IF condition

    Hello,

    For a few ID's (11454 and 1407), I am receiving a #NUM! error.

    Can you take a look at these? I can re-upload my sample if that helps.

  4. #4
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Outputting Values to New Column Based on ID and IF condition

    Doesnt happen in my file....
    Please upload the file where you are using the formula

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

    Re: Outputting Values to New Column Based on ID and IF condition

    I attached my sample with those messages.
    Attached Files Attached Files

  6. #6
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Outputting Values to New Column Based on ID and IF condition

    Formula should be in K2

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

    Re: Outputting Values to New Column Based on ID and IF condition

    I had updated the sample (attached) in Column L with the formula you had provided.
    On my end:

    ID: 11454 has 4 rows
    The first two are #NUM! and the last rows are '-'.

    ID: 1407 has 4 rows and all are equal to #NUM!

    I am using Microsoft Office Professional Plus 2016.

  8. #8
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Outputting Values to New Column Based on ID and IF condition

    Sorry, didnt tell you that it's a n array formula meaning:

    Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).

  9. #9
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Outputting Values to New Column Based on ID and IF condition

    or you can just replace the SUM with SUMPRODUCT;

    =IF(SUM(($A$2:$A$46=A2)*($D$2:$D$46&$I$2:$I$46<>"FFFTABC w/ I"))>=COUNTIF($A$2:$A$46,A2),"No Scenarios",IF(J2="","-",INDEX($J$1:$J$46,AGGREGATE(15,6,(ROW($A$2:$A$46)/(($A$2:$A$46=A2)*($D$2:$D$46="FFFT")*($I$2:$I$46="ABC W/ I"))),1))&IFERROR("/"&INDEX($J$1:$J$46,AGGREGATE(15,6,(ROW($I$2:$I$46)/(($A$2:$A$46=A2)*($D$2:$D$46="FFFT")*($I$2:$I$46="ABC W/ I"))),2)),"")&IFERROR("/"&INDEX($J$1:$J$46,AGGREGATE(15,6,(ROW($I$2:$I$46)/(($A$2:$A$46=A2)*($D$2:$D$46="FFFT")*($I$2:$I$46="ABC W/ I"))),3)),"")))

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

    Re: Outputting Values to New Column Based on ID and IF condition

    Thanks! Any way to do this without an array?

  11. #11
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Outputting Values to New Column Based on ID and IF condition

    with sumproduct as suggested in the last post

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

    Re: Outputting Values to New Column Based on ID and IF condition

    OK, i'm trying using SUMPRODUCT, but still getting that #NUM! error still in those same columns.

    Any idea on how to address that?

  13. #13
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Outputting Values to New Column Based on ID and IF condition

    Please attach again your file with the errors, I will look at that

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

    Re: Outputting Values to New Column Based on ID and IF condition

    Please try at K2

    =IFNA(LOOKUP(2,1/($A$2:$A$46=A2)/($D$2:$D$46="FFFT")/($I$2:$I$46="ABC w/ I"),$J$2:$J$46)&MID(REPT("/-",COUNTIFS($A$2:$A$46,A2,$D$2:$D$46,"FFFT",$I$2:$I$46,"ABC w/ I",$J$2:$J$46,"")),2,20),"No Secenarios")
    Attached Files Attached Files

  15. #15
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365 for MAC
    Posts
    3,105

    Re: Outputting Values to New Column Based on ID and IF condition

    Bo_Ry - Cells 18-27 and 44-46 do not comply with what he asks...he wants all scenarios met to be displayed in the cell...

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

    Re: Outputting Values to New Column Based on ID and IF condition

    @belinda Thanks, without textjoin function need multiple ampersands.
    K2
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

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

    Re: Outputting Values to New Column Based on ID and IF condition

    That last formula is outputting what I need!

    Two questions to see if this is possible.

    1)
    In my data, there are a few scenario's where the output just keeps repeating beacuase of the data.

    CCCR/CCCR/CCCR/CCCR/CCCR/TPAR/TPAR/TPAR/TPAR/TPAR/TPAR/TPAR/TPAR/TPAR/TPAR

    Can that be capped to show only the first instance of each scenario? Something like CCCR/TPAR instead of every instance?

    2) My real data has an example like "Mickey Mouse" but that "/" creates "Mickey/Mouse Any way to address that so any data with spaces do not have that slash, just between actual differences in the values?

    I can upload a few additional examples if needed.

    Thank you !

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

    Re: Outputting Values to New Column Based on ID and IF condition

    Please try

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

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

    Re: Outputting Values to New Column Based on ID and IF condition

    Thank you so much, this looks very good.

    One last update.

    As I'm reviewing the data, can we cap those situations to where there is no data in Column J?

    The ID 1130 is a great example where we currently output -/-/-/-/-
    For that scenario, where there are more than 1 row that qualifies, but all data is blank in Column J, can we do a '-' instead?

    This would also be great to apply to an example where it currently outputs: -/-/-/-/-/-/CCCR to just do -/CCCR (basically allow for only instance of '-' to be output if there are multiple rows that qualify.

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

    Re: Outputting Values to New Column Based on ID and IF condition

    Please provide a file with more representative data and the expected result.

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

    Re: Outputting Values to New Column Based on ID and IF condition

    I added some additional examples beginning in line 47 with the expected result.

    These would be these examples where I would like to remove duplicate '-' values but keep the rest of the formula as-is.

    Column M is the current formula, Column N is the expected value.
    Attached Files Attached Files

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

    Re: Outputting Values to New Column Based on ID and IF condition

    Please try

    =IF(COUNTIFS($A$2:$A$130,A2,$D$2:$D$130,"FFFT",$I$2:$I$130,"ABC w/ I"),
    SUBSTITUTE(SUBSTITUTE(TRIM(
    IF(COUNTIFS($A$2:$A$130,A2,$D$2:$D$130,"FFFT",$I$2:$I$130,"ABC w/ I",$J$2:$J$130,""),"-",)
    &IF(COUNTIFS($A$2:$A$130,A2,$D$2:$D$130,"FFFT",$I$2:$I$130,"ABC w/ I",$J$2:$J$130,"CCCR")," CCCR",)
    &IF(COUNTIFS($A$2:$A$130,A2,$D$2:$D$130,"FFFT",$I$2:$I$130,"ABC w/ I",$J$2:$J$130,"TPAR")," TPAR",)
    &IF(COUNTIFS($A$2:$A$130,A2,$D$2:$D$130,"FFFT",$I$2:$I$130,"ABC w/ I",$J$2:$J$130,"DPAC")," DPAC",)
    &IF(COUNTIFS($A$2:$A$130,A2,$D$2:$D$130,"FFFT",$I$2:$I$130,"ABC w/ I",$J$2:$J$130,"VVVR")," VVVR",)
    &IF(COUNTIFS($A$2:$A$130,A2,$D$2:$D$130,"FFFT",$I$2:$I$130,"ABC w/ I",$J$2:$J$130,"Mickey Mouse")," Mickey_Mouse",))," ","/"),"_"," "),"No Secenarios")
    Attached Files Attached Files

+ 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: 2
    Last Post: 07-04-2017, 03:20 PM
  2. count values from one column based on condition, with array
    By Siegfrid15 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-29-2017, 01:22 AM
  3. [SOLVED] Conditional Output Loop testing values in one column & outputting in another
    By bakeraj256 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-19-2014, 06:15 AM
  4. Replies: 3
    Last Post: 10-16-2013, 02:20 PM
  5. Outputting values in column B that correspond to certain values in column A
    By alvine in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-23-2010, 10:05 AM
  6. How to copy one column values to another column based on condition that row2 contain
    By sanjay19961 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-13-2010, 10:32 AM
  7. Add values in a column based on condition
    By finder003 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-28-2007, 07:16 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