+ Reply to Thread
Results 1 to 19 of 19

Help with this test buy

  1. #1
    Registered User
    Join Date
    09-29-2021
    Location
    US
    MS-Off Ver
    365
    Posts
    6

    Question Help with this test buy

    H i everyone, I'm a noob regarding excel and I have a question for you more advance users that maybe you can help me out:



    I created this as a test buy in which articles will constantly change every time the document is open, or they press F9. To do this, the following formula is in "Random" sheet in A# column:



    =INDEX(Some!A2:A18,RANDBETWEEN(1,ROWS(Some!A2:A18)),1)



    It gathers info from "Some" sheet, and it works well. Now what I want is to avoid showing articles with stock zero, and this is the part that I don't know how to do it.



    Any help, I appreciate it!



    Thanks.

    Attachment 767968
    Attached Files Attached Files
    Last edited by darkybot; 02-13-2022 at 12:16 PM.

  2. #2
    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,792

    Re: Help with this test buy

    Welcome to the forum.

    There are instructions at the top of the page explaining how to attach your sample workbook.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.

    Administrative Note:

    Although we value your privacy as much you do, it could be important that members have a rough idea of your location as the solutions they offer may be affected by your locale. For instance, you might in the future post questions which are related to your regional settings.

    With this in mind, please update your profile to something more precise (something such as UK, Europe, USA, UAE, etc. will suffice).

    Thank you for helping us to help you.
    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.

  3. #3
    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,792

    Re: Help with this test buy

    Administrative Note:

    We would very much like to help you with your query, however it has been brought to our attention that the same query has been posted on one or more other forums and you have not provided the required cross-post link(s) here.

    Please see Forum Rule #3 about cross-posting and adjust accordingly. Read this to understand why we (and other sites like us) consider this to be important.

    (Note: this requirement is not optional. As you are new here, I will do it for you this time: https://www.mrexcel.com/board/thread...-zero.1196008/)

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

    Re: Help with this test buy

    You left out (I think) one further requirement... that items selected should NOT repeat. So... non-zero stock non-repeating random selection generated by:

    =LET(n,COUNTIF(Some!D:D,">0"),r,SEQUENCE(n),s,INDEX(Some!A:A,AGGREGATE(15,6,ROW(Some!$D$2:$D$32)/(Some!$D$2:$D$32>0),r)),INDEX(s,AGGREGATE(15,6,r/NOT(COUNTIF($A$1:A1,INDEX(s,r))),RANDBETWEEN(1,n-ROW(A1)))))

    and then

    =VLOOKUP($A2,Some!$A:$D,COLUMNS($A2:B2),FALSE)

    to return the other columns.
    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

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

    Re: Help with this test buy

    or... just one place to change the range under consideration:


    =LET(d,Some!$D$2:$D$100,n,COUNTIF(Some!D:D,">0"),r,SEQUENCE(n),s,INDEX(Some!A:A,AGGREGATE(15,6,ROW(d)/(d>0),r)),INDEX(s,AGGREGATE(15,6,r/NOT(COUNTIF($A$1:A1,INDEX(s,r))),RANDBETWEEN(1,n-ROW(A1)))))

  6. #6
    Registered User
    Join Date
    09-29-2021
    Location
    US
    MS-Off Ver
    365
    Posts
    6

    Re: Help with this test buy

    This is super helpful, it does the trick that I was looking help with, so many thanks! Would you mind explaining the formula you used? I want to understand it please!
    Thanks!

  7. #7
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Help with this test buy

    Another option would be
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    which will return 10 items

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

    Re: Help with this test buy

    Argghh! Must I?

    The basic formula at the heart of it is (not tailored to your sample... it's from a file I have here:

    INDEX(O:O,AGGREGATE(15,6,ROW($O$1:$O$7)/Additional conditionNOT(COUNTIF($N$1:N1, INDEX(O:O,ROW($O$1:$O$7)))), RANDBETWEEN(1,8-ROW(N1))))

    Cyan: looking at this range...

    Red - return the row number

    Green: Only those that have NOT been returned in an earlier cell

    Blue - generate a random number between 1 and 7 (in effect the number of values) dimisnishing by 1 on every row.

    Black and return the corresponding value from column O.

    Starting from there, I adjusted the ranges to suit your set-up and added another condition (purple text) to the effect that the value in D>0.

    The rest id just twiddly bits to make sure that the formula runs sommothly. LET just defines pharases that are repeated... but at its heart is:

    INDEX(A LIST OF NON-ZERO STOCK ITEMS,AGGREGATE(15,6,AN ARRAY OF NUMBERS 1,2,3, to the total /NOT(COUNTIF($A$1:A1,A LIST OF NON-ZERO STOCK ITEMS)),RANDBETWEEN(1,n-ROW(A1)))))

    Clear as mud??

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please select "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.

  9. #9
    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,036

    Re: Help with this test buy

    Best thing it to cut the sample down to a very few rows and then use

    Formulas/Formula auditing/evaluate formula

    to step through the process. It has to be a very few rows...as the windo is non-resizable and (painfully) small to read.
    Attached Files Attached Files

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

    Re: Help with this test buy

    Quote Originally Posted by Fluff13 View Post
    Another option would be
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    which will return 10 items
    I'm about to vanish for the night and haven't time to check... Fluff... will that also prevent the return of duplicate values??

  11. #11
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,078

    Re: Help with this test buy

    Yes it will. Even if the randarray returns 2 identical numbers you will get 2 different rows of the data as it's only being used to sort the filtered results.

  12. #12
    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,036

    Re: Help with this test buy

    Thanks. On phone now. I'll look and learn tomorrow.

  13. #13
    Registered User
    Join Date
    09-29-2021
    Location
    US
    MS-Off Ver
    365
    Posts
    6

    Re: Help with this test buy

    Thanks for the time on explaining this, I have another question: If an article have more than one location, how can I show all the locations?
    Last edited by AliGW; 02-13-2022 at 04:52 PM. Reason: PLEASE don't quote unnecessarily!

  14. #14
    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,036

    Re: Help with this test buy

    Show us what you mean by that on a sample sheet.

  15. #15
    Registered User
    Join Date
    09-29-2021
    Location
    US
    MS-Off Ver
    365
    Posts
    6

    Re: Help with this test buy

    The document has 3 Sheets. Sheet "Random" which has the x amount of articles to randomly show up, Sheet "Some" from which it takes the information and sheet "Locations" from which sheet "Some" takes the location information.
    What I don't know is how to display all locations of one product, how can I do that?
    Attached Files Attached Files

  16. #16
    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,036

    Re: Help with this test buy

    Confused. I assume Name = Product. Take "Name" Four in random. It appears 5 times on sheet "locations", but all at teh same location. So, what would you expect to see? Where would you expect to see it??

    please amend with expected results!!

    I am about to leave to get my neck stretched (literally) but will be back later... providing I survive the physio's assault.

  17. #17
    Registered User
    Join Date
    09-29-2021
    Location
    US
    MS-Off Ver
    365
    Posts
    6

    Re: Help with this test buy

    Hope this clarifies a bit better: When randomize article "Adios" will show up, but it only shows 1 location for this article when actually it has 5, what I want is to show all of them without repeating the same location and this is the part that I don't have a clue how to do it.

    Example: This is the current
    A# A.Name Location Stock
    567 Adios zcxz 3

    What I want is to show all locations for that article without repeating same location:
    A# A.Name Location Stock
    567 Adios zcxz 3
    567 Adios abcd 4
    567 Adios xxxx 6
    567 Adios adfg 8
    567 Adios sfsqa 10


    Good luck, hope you dont end up sideways reading this (that would mean you survived so that's good I guess? lol)
    Attached Files Attached Files

  18. #18
    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,036

    Re: Help with this test buy

    Does this work for you??
    Attached Files Attached Files

  19. #19
    Registered User
    Join Date
    09-29-2021
    Location
    US
    MS-Off Ver
    365
    Posts
    6

    Re: Help with this test buy

    Hi,

    It partially does the trick, shows all locations, but for some it repeat it, ideally you just want to see all of them without repetition. Also, is there a way to show it vertically, not horizontally?

    Example:

    A# A.Name Stock Location 1 Location 2 Location 3 Location 4 Location 5
    654 Dos 423342 ndsvjknahr2h asd1313
    4567 Four 6 42pjhlfahslh 42pjhlfahslh 42pjhlfahslh 42pjhlfahslh 42pjhlfahslh

    Gracias!
    Attached Files Attached Files
    Last edited by darkybot; 02-16-2022 at 02:18 PM.

+ 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: 8
    Last Post: 07-12-2018, 01:15 PM
  2. Replies: 3
    Last Post: 08-21-2013, 07:10 PM
  3. [SOLVED] Test if a cell is within a name range and return a text value based on the test
    By DraconR in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 06-24-2013, 02:46 AM
  4. Pull sub-test scores from test w/best overall test score (PSAT)
    By PowerSchoolDude in forum Excel General
    Replies: 0
    Last Post: 11-19-2009, 08:29 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