Closed Thread
Results 1 to 25 of 25

Formula to get unique data

Hybrid View

  1. #1
    Registered User
    Join Date
    05-18-2020
    Location
    India
    MS-Off Ver
    2013
    Posts
    13

    Formula to get unique data

    I have data in cell Q5:Q9, and amounts in P5:P9, where Q colum data is default and will input in same like that.
    P Q
    5 250 Expenses Airfare Aug-19
    6 500 Expenses Airfare Jul-19
    7 250 Expenses Airfare Jun-19
    8 500 Expenses Airfare May-19
    9 250 Expenses Airfare May-19

    Now, I need a formula in Q10:Q13, Single Text from Q5:Q9 if the amounts is related to same month. For Ex: Q13 will be "Expenses Airfare May-19" and P13 will be sum of 750. and the formula has to continue to next rows if there are other months too.
    P Q
    10​ 250 Expenses Airfare Aug-19
    11​ 500 Expenses Airfare Jul-19
    12​ 250 Expenses Airfare Jun-19
    13​ 750 Expenses Airfare May-19
    Attached Files Attached Files
    Last edited by Kishore K; 05-18-2020 at 03:23 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,717

    Re: Formula to get unique data

    Read the yellow banner at the top of this page on how to attach a file.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Registered User
    Join Date
    05-18-2020
    Location
    India
    MS-Off Ver
    2013
    Posts
    13

    Re: Formula to get unique data

    Hi Alan, have attached the file.

    Thank you..

  4. #4
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Formula to get unique data

    Assuming column P is not relevant and your attachment does not match with your description
    if the dates in the cell you are matching against are dates
    =SUMIF($R$5:$R$14,"*"&TEXT(T6,"mmm-yy"),$Q$5:$Q$14) where t6 is the date

    or if text
    =SUMIF($R$5:$R$14,"*"&RIGHT(t6,6),$Q$5:$Q$14)

  5. #5
    Registered User
    Join Date
    05-18-2020
    Location
    India
    MS-Off Ver
    2013
    Posts
    13

    Re: Formula to get unique data

    Hi, sorry for that confusion in excel file. i have tried to put the formula but i am getting blank data.
    Attached Files Attached Files

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

    Re: Formula to get unique data

    Davsth - Which cell has this formula, and what would be on column T that you refer to in your formula?

  7. #7
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365
    Posts
    3,187

    Re: Formula to get unique data

    Not really clear what you are trying to achieve.
    In Q15 you are expecting to see "Expenses Airfare May-19" because the value in B15 is equal to the value in P8 and then you want to return the same text that it has?
    You have another 500 in P5 with another text. So you want the formula to search for the last matching value and return its text in column Q?

  8. #8
    Registered User
    Join Date
    05-18-2020
    Location
    India
    MS-Off Ver
    2013
    Posts
    13

    Re: Formula to get unique data

    Hi, let me explain this. Data in Q5:Q14 is constant with text, expense data with various months, as well in P5:P15 with amounts. the Expense months may vary or similar months. now i need a formula in Q15, like, cost for Aug-19 is $500 and Q15 will be "Expenses Airfare Aug-19" and in P15 $500. Wheres as for repeated months for ex, in Q18 i will need data clubbing of May-19 as a whole and sum of May-19 in P18 $1300 ($500+350+450). and the Q19 has to be Oct-19 data and sum of $1,200(550+650) in P19.. So on..

    Hope i have put it fine..
    Attached Files Attached Files

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

    Re: Formula to get unique data

    Hi Kishore K,
    Thank you for the clarification. Now it is well understood, I will think about a proper solution, or maybe someone here will figure this out before me...

  10. #10
    Registered User
    Join Date
    05-18-2020
    Location
    India
    MS-Off Ver
    2013
    Posts
    13

    Re: Formula to get unique data

    Glad you got it.. hope this can have a better solution..

    Thank you

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

    Re: Formula to get unique data

    Hi,
    I managed to do that only with a helper though I'm sure it is possible without (with frequency function or something like that).

    So the helper in U5 and down would retrieve unique values, and leave blank cells for the duplicate lines (I couldnt find a way to overcome the blank cells):

    =IF(OR(COUNTIF($U$4:U4,INDEX($Q$1:$Q$14,SMALL(IF(Q5=$Q$1:$Q$14,ROW($Q$1:$Q$14),ROW(Q5)),1),1))>0,U4=INDEX($Q$1:$Q$14,SMALL(IF(Q5=$Q$1:$Q$14,ROW($Q$1:$Q$14),ROW(Q5)),1),1)),"",INDEX($Q$1:$Q$14,SMALL(IF(Q5=$Q$1:$Q$14,ROW($Q$1:$Q$14),ROW(Q5)),1),1))
    Then you can apply in Q15 and down the following formula that skips the blanks:

    =IFERROR(INDEX($Q$1:$Q$14,SMALL(IF($U$5:$U$13<>"",ROW($U$5:$U$13)),ROWS($U$5:U5)),1),"")

    Let me know if this what you need.
    Thanks.
    Attached Files Attached Files

  12. #12
    Forum Expert
    Join Date
    03-28-2014
    Location
    Hyderabad,India
    MS-Off Ver
    Office 365
    Posts
    1,899

    Re: Formula to get unique data

    Formula: copy to clipboard
    "Expenses Airfare"&" "&TEXT(T5,"mmm-yy")

    copy it in Q5 and drag it down.
    Punnam

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

    Re: Formula to get unique data

    If this is the technique then put in Q15:

    =INDEX($Q$5:Q14,MATCH(2,INDEX(1/($P$5:P14=P15),)),1)

  14. #14
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,706

    Re: Formula to get unique data

    another alternative, if I have understood

    Formula: copy to clipboard
    Q15:
    =INDEX($Q:$Q,AGGREGATE(15,6,ROW($Q$5:$Q$14)/(SUMIF($Q$5:$Q$14,$Q$5:$Q$14,$P$5:$P$14)=$P15)/(MATCH($Q$5:$Q$14,$Q$5:$Q$14,0)=(ROW($Q$5:$Q$14)-ROW($Q$5)+1)),COUNTIF($P$15:$P15,$P15)))
    copied down
    the above assumes monthly totals could repeat, e.g. if P14 were 550 rather than 350 -- in which case the above would assign first found, then second found etc
    if the monthly totals are guaranteed to be unique, then:
    Formula: copy to clipboard
    Q15:
    =INDEX($Q$5:$Q$14,MATCH($P15,INDEX(SUMIF($Q$5:$Q$14,$Q$5:$Q$14,$P$5:$P$14),0),0))
    copied down

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

    Re: Formula to get unique data

    Hi Xlent,

    Q15 gives a zero. Can you please upload it in excel? I will be happy to see another solution.
    Just to make it clear - the purpose is that the below duplicate lines should appear only 1 time (the lines with the text containing May/Oct/Sep).
    then - a sumif function will be effected in column P

    Thanks.

    Expenses Airfare Aug-19
    Expenses Airfare Jul-19
    Expenses Airfare Jun-19
    Expenses Airfare May-19
    Expenses Airfare May-19
    Expenses Airfare May-19
    Expenses Airfare Oct-19
    Expenses Airfare Oct-19
    Expenses Airfare Sep-19
    Expenses Airfare Sep-19

  16. #16
    Registered User
    Join Date
    05-18-2020
    Location
    India
    MS-Off Ver
    2013
    Posts
    13

    Re: Formula to get unique data

    Thank you all, that should do..


  17. #17
    Registered User
    Join Date
    05-18-2020
    Location
    India
    MS-Off Ver
    2013
    Posts
    13

    Sales

    Hi,

    Please help with a formula for below.
    Having data in A5:C12. Where I wanted the data in A16 with "Sales & Department &month" data by eliminating the blanks in between for various months

    MONTH DEPT. SALES
    Jan-20 12110 500
    13110 300
    14110
    15110 100
    Feb-20 13110 200
    12110
    15110 300


    SUMMARY
    SALES 12110 JAN-20 500
    SALES 13110 JAN-20 300
    SALES 15110 JAN-20 100
    SALES 13110 FEB-20 200
    SALES 15110 FEB-20 300
    Attached Files Attached Files

  18. #18
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,706

    Re: Formula to get unique data

    I had assumed the values in P15 onwards existed to which the OP was trying to assign the correct label, if that's not the case, i.e. generate unique aggregates of rows 5:14 then:

    Formula: copy to clipboard
    Q15: =INDEX($Q$5:$Q$14,AGGREGATE(15,6,(1+ROW($Q$5:$Q$14)-ROW($Q$5))/(MATCH($Q$5:$Q$14,$Q$5:$Q$14,0)=(1+ROW($Q$5:$Q$14)-ROW($Q$5))),ROWS(Q$15:Q15)))
    P15: =SUMIF($Q$5:$Q$14,$Q15,$P$5:$P$14)
    copied down
    but a Pivot Table would make more sense if that's the case.

  19. #19
    Registered User
    Join Date
    05-18-2020
    Location
    India
    MS-Off Ver
    2013
    Posts
    13

    Re: Formula to get unique data

    Hi,

    Thank you with the formula, this is working fine.. but if we extend the formula in same excel sheet in Q column, the formula is throwing error. I wanted to apply the formula Q23:Q30 (this may go on to Q50 depends on number of expenses). please help
    Attached Files Attached Files

  20. #20
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365
    Posts
    3,187

    Re: Formula to get unique data

    OK. This is it.
    Thank you very much for sharing your knowledge!

  21. #21
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365
    Posts
    3,187

    Re: Formula to get unique data

    Hi Kisore,

    Xlent's formula is working very well without a helper , but if you want to apply it on a new segment you will have to change the range in bold to reflect the new range.
    Does the extent of your segment going to be a lot wider than in your example? (the Maximum range in the below adjusted formula is 24 lines)

    I added lines to your example just to test it.

    In Q36
    =INDEX($Q$23:$Q$33,AGGREGATE(15,6,(1+ROW($R$1:$R$24)-ROW($R$1))/(MATCH($Q$23:$Q$33,$Q$23:$Q$33,0)=(1+ROW($R$1:$R$24)-ROW($R$1))),ROWS(Q$23:Q23)))
    Attached Files Attached Files

  22. #22
    Forum Expert
    Join Date
    09-07-2014
    Location
    Israel
    MS-Off Ver
    office 365
    Posts
    3,187

    Re: Formula to get unique data

    Regarding the formula you found on the net, see below how it is customized for your new segment.

    It is less practical as I had to calculate what should be the number of rows in the array (ROW(Q$5:Q$12)-4) in order for it to match the exact number of rows in the data array (MATCH(Q$23:Q$30,Q$23:Q$30,)). If the ranges do not match in quantity it returns N/A

    So the ranges will look like that - 8 characters in each array:
    {1;1;3;4;5;5;7;7}={1;2;3;4;5;6;7;8}

    Unless you or someone here finds a way to overcome that - and assuming your ranges are changing - perhaps this formula is less recommended.

    Q31 and down (Bold needs to be adjusted:
    =IFERROR(INDEX(Q$23:Q$30,SMALL(IF(MATCH(Q$23:Q$30,Q$23:Q$30,)=ROW(Q$5:Q$12)-4,ROW(Q$5:Q$12)-4),ROW(A1))),"")
    Attached Files Attached Files

  23. #23
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,651

    Re: Formula to get unique data

    Try
    Q15=Q5
    Q16:
    =IFERROR(INDEX($Q$5:$Q$14,MATCH(0,COUNTIF($Q$15:Q15,$Q$5:$Q$14),0)),"")
    **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).
    Drag down
    Similar to next section:
    Q31=Q23
    Q32:
    =IFERROR(INDEX($Q$23:$Q$30,MATCH(0,COUNTIF($Q$31:Q31,$Q$23:$Q$30),0)),"")
    Also Control-Shift-Enter
    Drag down
    Quang PT

  24. #24
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,717

    Re: Formula to get unique data

    OP has opened a new thread on this latest issue at https://www.excelforum.com/excel-for...713-sales.html. Am closing this thread as OP has indicated that it has been resolved.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Looking for a formula to rank data and output unique value
    By hawaean in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-06-2020, 02:16 AM
  2. Formula to Extract Unique Data
    By Legalhustler in forum Excel General
    Replies: 20
    Last Post: 07-16-2015, 11:23 AM
  3. Count formula for multiple and unique data
    By RMSmith3 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-10-2015, 05:29 PM
  4. Formula for finding unique data for lists
    By alcorp in forum Excel General
    Replies: 15
    Last Post: 07-21-2014, 03:49 PM
  5. [SOLVED] Summarising Data using a unique list formula
    By pauldaddyadams in forum Excel Formulas & Functions
    Replies: 21
    Last Post: 07-25-2013, 11:11 AM
  6. Dynamic Formula that summarizes data by unique values only
    By Trax in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-15-2013, 09:08 AM
  7. How to get unique counts from large data by formula
    By irfan.rangrej in forum Excel General
    Replies: 5
    Last Post: 08-30-2011, 07:39 AM

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