+ Reply to Thread
Results 1 to 22 of 22

Populating fields to create a flat file

  1. #1
    Registered User
    Join Date
    06-12-2021
    Location
    Montreal, Canada
    MS-Off Ver
    Office 365
    Posts
    49

    Populating fields to create a flat file

    Good day,

    I have a file that containes multiple recepient names per drugstore with a quantity and a reward code separated with a pipe. I need to create a flat file from the data to create an import file for our shipping software.

    I have provided a sample. In the example. I have a unique drugstore with the up to 9 cosmeticians that have taken various online classes. The rewards codes (A-B-C-D) are preceded with the qty of reward they should get. I would like to be able to create a flat file that I will be able to import directly into our in house shipping program. It could also be a flat file created for a relational operation.

    Thank you for your help,

    Yves
    Attached Files Attached Files

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

    Re: Populating fields to create a flat file

    What you have shown in the workbook is NOT a traditional flat file database. In a normalised flat file DB, each row will contain ONE record only. Does the layout have to be what you have shown, therefore, or are you open to a properly normalised solution?
    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 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,053

    Re: Populating fields to create a flat file

    Why are Diep Vy's items all prefixed with a 2 (L21, etc) when there is no obvious reason (that I can see)??
    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

  4. #4
    Registered User
    Join Date
    06-12-2021
    Location
    Montreal, Canada
    MS-Off Ver
    Office 365
    Posts
    49

    Re: Populating fields to create a flat file

    Hi,

    Yes Ali I am open to properly normalized solution.

    Glenn, in the file supplied to me, the name of Diep Vy is getting those items multple times. I think the cosmeticians can take the same online class multiple times and that generates multiple orders for the same reward to be sent. I don't control the input website, I just get the data gathered. I need to unified all the rewards being sent to one package per drugstore to minimize cost and be greener.

    Yves

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

    Re: Populating fields to create a flat file

    Yes... I have just spotted that. It might mess up the approach I was taking, which was to split the item A's out into separate cells for each person...

  6. #6
    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,053

    Re: Populating fields to create a flat file

    I assume that this layout (purple and tan cells ONLY have been "done") is no use to you...
    Attached Files Attached Files

  7. #7
    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,053

    Re: Populating fields to create a flat file

    Is it possible to have numbers OTHER than 1 in these bits:

    •1|A•1|A•1|B•1|B

  8. #8
    Registered User
    Join Date
    06-12-2021
    Location
    Montreal, Canada
    MS-Off Ver
    Office 365
    Posts
    49

    Re: Populating fields to create a flat file

    Glenn,

    At the moment, if the qty are different then 1, they would have been manually entered by the client for internal usage. I scan for them early in the job, pull them and treat them separately. So no, they qty will not differ from 1.

    Yves

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

    Re: Populating fields to create a flat file

    So... is the layout (tan and purple cells ONLY have been worked on... at Post 6) any use?

  10. #10
    Registered User
    Join Date
    06-12-2021
    Location
    Montreal, Canada
    MS-Off Ver
    Office 365
    Posts
    49

    Re: Populating fields to create a flat file

    Glenn,

    If the same items are listed twice (L21,M21) for 1 name, the 4 items enumeration will not be able to handle a reward counts higher than 4 (cell F6).

    Yves

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

    Re: Populating fields to create a flat file

    So... no it's no good???

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

    Re: Populating fields to create a flat file

    I have got it working... maybe not in the simplest way... but it seems OK. Can you check the ORANGE cells by varying what's in the BLUE cells for Name 1 ONLY... to see if there are any bugs. I can then extend it to cover the other names.
    Attached Files Attached Files
    Last edited by Glenn Kennedy; 06-25-2021 at 08:41 AM.

  13. #13
    Registered User
    Join Date
    06-12-2021
    Location
    Montreal, Canada
    MS-Off Ver
    Office 365
    Posts
    49

    Re: Populating fields to create a flat file

    Tx Glenn,

    I have tried adding many mode instances of A-B-C-D for the first name. I works very well.

    Yves

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

    Re: Populating fields to create a flat file

    Away for some exercise. I'll finish it in acouple of hours.

  15. #15
    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,053

    Re: Populating fields to create a flat file

    Hopefully, that's it....

    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 above and mark this thread as SOLVED.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    06-12-2021
    Location
    Montreal, Canada
    MS-Off Ver
    Office 365
    Posts
    49

    Re: Populating fields to create a flat file

    Good day,

    Glenn, I had to chance to try your solution at length. If more recipients are added by the client, I managed to modify your solution successfully but if the number of items gifted gets larger, I did not manage to successfully modify the formula to get conclusive results. I have tried to modify the $A$11:$B:14 to reflect the new item codes (letter) and the item descriptions but I think I am missing something to make it work.

    Yves

  17. #17
    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,053

    Re: Populating fields to create a flat file

    I was afraid you'd ask about that.... I am trying to persuade myself to go for a walk in the hills... I'll take a look to remind myself about this now... and will try to modify it later.

  18. #18
    Registered User
    Join Date
    06-12-2021
    Location
    Montreal, Canada
    MS-Off Ver
    Office 365
    Posts
    49

    Re: Populating fields to create a flat file

    Tx Glenn, have a nice walk.

    Yves

  19. #19
    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,053

    Re: Populating fields to create a flat file

    I started to get very confused... and simplified things a bit. The formula is now fully dynamic. It goes in N11 and is copied down. it spills into the remaining columns. The nomenclature was a tad confusing.

    If you need to add more ITEMS (cols AC to AD), you need to change the formula bits in red appropriately.

    if you need to add more Name/Areas, change the bits in green.

    Other than that, the only thing that still requires manual alteration is the headers in I10 and to the right.

    Play with it a bit before restoring the names as you had them before!!

    =IFERROR(LET(
    A,COUNTA($AD$2:$AD$7),
    B,INT(SEQUENCE(,A*COUNTA($I$1:$M$1),1,1/A)),
    C,INDEX($I2:$M2,B),
    D,INDEX($I11:$M11,B),
    E,1+MOD(SEQUENCE(,A*COUNTA($I$1:$M$1),1,1)-1,A),
    F,"<X><Y>"&SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(C,D,""),"•","",1),"•","|"),"|","</Y><Y>")&"</Y></X>",
    G,"//Y[position() mod 2 = 0 and not(preceding::*=.)]["&E&"]",
    (LEN(C)-LEN(SUBSTITUTE(C,"•1|"&FILTERXML(F,G),"")))/4&"-"&VLOOKUP(FILTERXML(F,G),$AC$2:$AD$7,2,FALSE)),"")

  20. #20
    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,053

    Re: Populating fields to create a flat file

    Argghh. And the file!!
    Attached Files Attached Files

  21. #21
    Registered User
    Join Date
    06-12-2021
    Location
    Montreal, Canada
    MS-Off Ver
    Office 365
    Posts
    49

    Re: Populating fields to create a flat file

    Hello Glenn,

    I have played with the formula. It works very well when I switch for my original data. One exception, I don't understand the result at position AK11.

    Tx.

    Yves

  22. #22
    Registered User
    Join Date
    06-12-2021
    Location
    Montreal, Canada
    MS-Off Ver
    Office 365
    Posts
    49

    Re: Populating fields to create a flat file

    I have found that the only 5 items instead of 6 are listed from AF11 to AJ15.

    I have looked at the suggested changes (red and green) but it does not add the extra A4 Item 6 header and column.

    Yves

+ 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. Macro to compare two flat files and copy missing value to new flat file
    By pratheepm7 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-21-2017, 02:15 PM
  2. [SOLVED] wish to create 8 column flat file from 43 column, 10,000 row spreadsheet
    By RuthMP in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 02-13-2014, 01:34 PM
  3. [SOLVED] Excel macro to create a flat file?
    By jlang11 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-18-2013, 03:05 PM
  4. Formula or VBA to fill down a hierarchy to create a flat file
    By bmb163 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-28-2012, 09:34 AM
  5. Create flat file from data download
    By msmithdynamicsgp in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2011, 09:54 PM
  6. Create Flat File from Macro
    By jackfsm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2009, 02:15 PM
  7. Fields not aligning when exporting data to a flat file
    By danchik in forum Excel General
    Replies: 1
    Last Post: 01-18-2007, 07:15 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