+ Reply to Thread
Results 1 to 13 of 13

Filter out repeating values and apply formula on the second or 4th value only

  1. #1
    Registered User
    Join Date
    08-26-2014
    Location
    Riyadh
    MS-Off Ver
    MS Office 365
    Posts
    24

    Filter out repeating values and apply formula on the second or 4th value only

    Dear Experts

    I need help on a long list of transactions where I want to filter out those customers who have traded more than one time and then apply a formula only to the second or fourth transaction to calculate the discount value. Is it possible through Forumla or Macro will be better? Example data below

    Date Customer Number Revenue
    2-Nov-18 5005542746 1,147
    2-Nov-18 5005542746 640
    26-Oct-18 5005543078 3,967
    24-Oct-18 5005543080 270
    25-Oct-18 5005543080 102
    1-Nov-18 5005543080 270
    30-Oct-18 5005543080 11,161
    Attached Files Attached Files
    Last edited by Khalid.Noor; 11-11-2018 at 08:17 AM.

  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,061

    Re: Filter out repeating values and apply formula on the second or 4th value only

    Will you please attach a SMALL sample Excel workbook (10-20 rows of data is usually enough)? However, please give us an indication of the approximate number of rows of data you want the solution to work with (100, 1000, 100,000 or whatever). Please don't attach a picture of an Excel sheet (no-one will want to re-type all your stuff before starting).

    1. Make sure that your sample data are truly REPRESENTATIVE of your real data. The use of unrepresentative data is very frustrating and can lead to long delays in reaching a solution.

    2. Make sure that your desired solution is also shown (mock up the results manually).

    3. Make sure that all confidential information is removed first!!

    4. Try to avoid using merged cells. They cause lots of problems!

    Unfortunately the attachment icon doesn't work at the moment. So, to attach an Excel file you have to do the following: Just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.
    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
    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,061

    Re: Filter out repeating values and apply formula on the second or 4th value only

    How does excel know WHICH one to choose... the 2nd or the 4th???

  4. #4
    Registered User
    Join Date
    08-26-2014
    Location
    Riyadh
    MS-Off Ver
    MS Office 365
    Posts
    24

    Re: Filter out repeating values and apply formula on the second or 4th value only

    Thank you very much for the guidance. Please see the attached file.

    1. Now the original form of the data is attached.

    2. If the customer repeats more than one but less than 4 then choose 2nd transaction, 4th transaction if the transactions are equal to 4 or exceeds 4.
    Attached Files Attached Files

  5. #5
    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,061

    Re: Filter out repeating values and apply formula on the second or 4th value only

    You did not show what your expected results should look like (see point 2 -in red - in my previous post). I had hoped that you would read it if it was in an eye-catching colour. But you didn't. So... I guessed:

    =IF(COUNTIF($B$5:B5,B5)=2,0.85*C5,IF(COUNTIF($B$5:B5,B5)=4,0.8*C5,C5))

    copied down.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    08-26-2014
    Location
    Riyadh
    MS-Off Ver
    MS Office 365
    Posts
    24

    Re: Filter out repeating values and apply formula on the second or 4th value only

    My Gosh ... You are right, I totally skipped the point.

    The solution worked great .... thanks alot. Only I want to see if the transactions are 4 or more than 4 then calculation on second transaction needs to be skipped and should be performed only on 4th.

  7. #7
    Registered User
    Join Date
    08-26-2014
    Location
    Riyadh
    MS-Off Ver
    MS Office 365
    Posts
    24

    Re: Filter out repeating values and apply formula on the second or 4th value only

    Can I add another scenario?

    If the transactions repeat twice then apply .85 x( 1st + 2nd transaction) and if it repeats 4 or more than 4 times then .8 x (3rd + 4th).

  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 2403
    Posts
    44,061

    Re: Filter out repeating values and apply formula on the second or 4th value only

    Then use either this:

    =IF(COUNTIF($B$5:B5,B5)=4,0.8*C5,IF(AND(COUNTIF(B:B,B5)<=2,COUNTIF($B$5:B5,B5)=2),0.85*C5,""))

    or this:

    =IF(COUNTIF($B$5:B5,B5)=4,0.8*C5,IF(AND(COUNTIF(B:B,B5)<=2,COUNTIF($B$5:B5,B5)=2),0.85*C5,C5))

    depending on whether or not you want to see the undiscounted value
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    08-26-2014
    Location
    Riyadh
    MS-Off Ver
    MS Office 365
    Posts
    24

    Re: Filter out repeating values and apply formula on the second or 4th value only

    Well done.

    Can I add another scenario?

    If the transactions repeat twice then apply .85 x( 1st + 2nd transaction) and if it repeats 4 or more than 4 times then .8 x (3rd + 4th).

  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 2403
    Posts
    44,061

    Re: Filter out repeating values and apply formula on the second or 4th value only

    Is this "instead of" or "as well as" the previous conditions?

  11. #11
    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,061

    Re: Filter out repeating values and apply formula on the second or 4th value only

    Duhh! It has to be instead of...

    =IF(AND(COUNTIF(B:B,B5)>=4,OR(COUNTIF($B$5:B5,B5)=3,COUNTIF($B$5:B5,B5)=4)),0.8*C5,IF(COUNTIF(B:B,B5)=2,0.85*C5,""))

    or

    =IF(AND(COUNTIF(B:B,B5)>=4,OR(COUNTIF($B$5:B5,B5)=3,COUNTIF($B$5:B5,B5)=4)),0.8*C5,IF(COUNTIF(B:B,B5)=2,0.85*C5,C5))

    depending on whether or not you want to see the unmodified values.
    Attached Files Attached Files

  12. #12
    Registered User
    Join Date
    08-26-2014
    Location
    Riyadh
    MS-Off Ver
    MS Office 365
    Posts
    24

    Re: Filter out repeating values and apply formula on the second or 4th value only

    That's brilliant.

    You are amzing Glen. Thanks alot.

  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 2403
    Posts
    44,061

    Re: Filter out repeating values and apply formula on the second or 4th value only

    You're welcome.



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

    It'd also be appreciated if you were to click the Add Reputation button at the foot of any of the posts of all members who helped you reach a solution.

+ 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. Using VBA to apply values in a range to the filter in a Pivot Table
    By PFDave in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-06-2017, 09:17 AM
  2. Macro: Filter spreadsheet, then apply formula to results
    By RC-AMG in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-26-2015, 08:14 AM
  3. [SOLVED] make filter automatically re-apply when cell values change
    By tlacloche in forum Excel Programming / VBA / Macros
    Replies: 23
    Last Post: 04-02-2013, 06:44 PM
  4. How to apply filter in sheet on (Bold entries and values) only?
    By motivationalist in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-25-2012, 09:54 AM
  5. creating a repeating formula that doesn't show repeating values
    By cybershot in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 12-09-2010, 06:12 PM
  6. Replies: 2
    Last Post: 05-18-2010, 07:46 PM
  7. Replies: 1
    Last Post: 01-13-2005, 03:38 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