+ Reply to Thread
Results 1 to 20 of 20

Trying to modify a complex formula that outputs a spilled result in multiple columns

  1. #1
    Registered User
    Join Date
    11-23-2022
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    9

    Post Trying to modify a complex formula that outputs a spilled result in multiple columns

    Hi everyone!

    I'm working with a complex formula and trying to make some changes. See below for the formula. The formula retrieves data from an extensive drug database (20K+ lines). It then outputs a spilled result into three separate columns, which are ordered by the drug strength, pharmaceutical form, and DIN (drug identification number). See the screenshot below. I also attached some sample data with the formula.

    Screenshot.png

    I did not write this formula, so it is beyond my understanding. I'm trying to modify the formula so that it spills the 4th column for the route of administration and for this column to come after "Dosage Form" and before the "DIN/PDIN/NPN" column. The drug database I'm using contains both marketed and approved drugs. I'm also trying to get the formula to separate DINs into different columns depending on whether the product is marketed or approved. The end result would be the formula spilling out five columns. I hope what I'm asking makes sense. Let me know if you require additional clarification! I appreciate any help you can provide.

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by steelrends; 11-26-2022 at 03:25 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 2406
    Posts
    44,662

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    "fairly complex" is a bit of an understatement. It >>looks<< totally over the top!

    Is there always only ONE code in column B... or can there be multiple codes?

    Your sample is oversimplified if that's the case.
    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

  3. #3
    Registered User
    Join Date
    11-23-2022
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    Hi yes Column B may have multiple codes in some cases... I probably should have used a better example

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,379

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    You should have, yes. Please provide one that is realistic.
    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. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    11-23-2022
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    Updated sample that is more realistic

  6. #6
    Registered User
    Join Date
    11-23-2022
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    Still need help with this problem. I have uploaded new screenshot and sample data containing only one drug table vs. two previously (combined them) to make it easier

  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 2406
    Posts
    44,662

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    And the expected results, calculated manually are... where?

  8. #8
    Registered User
    Join Date
    11-23-2022
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    Bump. Posted expected results, which are calculated manually

  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 2406
    Posts
    44,662

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    OK. 99% of the way there.

    My output is 2 lines longer than yours. In your formula, IV and IM preparations at the same dose are combined in ONE line. In mine, there are two.

    IF you want that to be addressed are there other posssible combinations that should also be concatenated (e.g. SC and IM)?

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

  10. #10
    Registered User
    Join Date
    11-23-2022
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    Hi Glenn!

    Thank you so much for providing me with the formula with the sample. Your formula uses the entire ATC column from the DPD table. I was wondering how I would go about using it for specific drugs. Ex. If I want the formula to generate a result for all drugs that contain cyproheptadine as the only ingredient (number of AIS = 1). This was why I included
    Please Login or Register  to view this content.
    , with cell A5 containing the name of the drug, in the previous formula.

    I glanced at the entirety of the data I'm working with... I found quite a bit of route of administration combinations for the same drug and dose. I listed some below, but there's a good chance that I've missed some. Could you show me how you would concatenate these route of administration combinations into your formula?

    - Inhalation, Oral
    - Intramuscular, Intravenous
    - Intramuscular, Intratracheal, Intravenous, Subcutaneous
    - Intramuscular, Subcutaneous
    - Intravenous, Subcutaneous
    - Intramuscular, Topical
    - Ophthalmic, Otic
    - Otic, Topical
    - Intramuscular, Intravenous, Subcutaneous
    - Intrathecal, Intravenous, Subcutaneous
    - Oral, Topical
    - Intra-Articular, Intralesional, Intramuscular, Intrasynovial
    - Intramuscular, Intrasynovial
    - Intralesional, Intramuscular, Intrasynovial
    - Intramuscular, Intrasynovial, Intravenous
    - Intraperitoneal, Irrigation
    - Rectal, Topical
    - Block/Infiltration, Intra-Articular, Epidural
    - Block/Infiltration, Epidural
    - Block/Infiltration, Intramuscular, Subcutaneous, Epidural
    - Intraperitoneal, Intravenous, Subcutaneous
    - Intra-Articular, Intramuscular, Intravenous
    - Intramuscular, Intraperitoneal, Intravenous, Subcutaneous
    - Intracardiac, Intrapulmonary, Intravenous
    - Intracardiac, Intraperitoneal, Intrapulmonary, Intravenous
    - Intracardiac, Intravenous
    - Intracardiac, Intramuscular, Intratracheal, Intravenous, Subcutaneous
    - Intravenous, Subcutaneous, Epidural
    - Intramuscular, Subcutaneous, Epidural
    - Intra-Articular, Intramuscular
    - Intra-Articular, Intrabursal, Intradermal, Intrasynovial
    - Intra-Articular, Periarticular, Intrabursal, Intrasynovial
    - Intra-Articular, Intrabursal, Intradermal, Intramuscular
    - Intra-Articular, Intralesional, Intramuscular, Intravenous, Soft Tissue Injection
    - Intra-Articular, Periarticular, Intrasynovial
    - Intradermal, Subcutaneous
    - Intradermal, Inhalation, Intravenous, Oral
    - Topical, Vaginal
    - Oral, Rectal
    - Intra-Arterial, Intravenous
    - Intra-Arterial, Intramuscular, Intravenous
    - Intradermal, Subcutaneous, Percutaneous
    - Intracerebroventricular, Intra-Arterial, Intramuscular, Intrathecal, Intravenous
    - Intra-Arterial, Intramuscular, Intrathecal, Intravenous
    - Intraperitoneal, Irrigation, Topical
    - Intracavitary, Parenteral (unspecified)
    - Intraperitoneal, Intravenous
    - Intraperitoneal, Intravenous, Oral
    - Inhalation, Intravenous
    - Teat-Dip, Topical
    - Intravenous, Intravesical
    - Subarachnoidal, Intravascular
    - Intra-Arterial, Intracavitary, Intramuscular, Intravenous, Subcutaneous
    - Intracutaneous, Subcutaneous
    - Intrauterine, Vaginal
    - Intramuscular, Intrauterine, Subcutaneous
    - Intramuscular, Intravenous, Epidural
    - Intramuscular, Intravenous, Subcutaneous, Intraperitoneal
    - Intravenous, Epidural
    - Intravenous, Oral
    - Retrobulbar, Epidural
    - Intracaudal, Epidural
    - Nasogastric, Oral
    - Intravenous, Haemodialysis
    - Inhalation, Intravenous, Oral
    - Nasal, Oral
    - Intramuscular, Intrapleural, Intravenous, Subcutaneous
    - Intraglandular, Intramuscular
    - Instillation, Intravenous, Oral
    - Buccal, Sublingual
    - Buccal, Oral
    - Infiltration, Epidural
    - Topical, Udder Wash
    - Interstitial, Intravenous
    - Nerve Block, Epidural
    Last edited by steelrends; 11-27-2022 at 06:08 AM.

  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 2406
    Posts
    44,662

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    OMG!

    Plan B went out the window when I saw that...

    Plan C took a while, as I had to double back and start over again, with some relatively unfamiliar stuff. However, here it is. Points:

    1. A added a cell in the first row to select the AIC code. The table will update.

    2. I duplicated the diphenhydramine data, changed ATC to chlorpheniramine and the AIC to (randomly) 188.

    It looks good to me. Check it over.
    Attached Files Attached Files
    Last edited by Glenn Kennedy; 11-27-2022 at 08:56 AM.

  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 2406
    Posts
    44,662

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    I should have added. Look at the yellow cells in the raw data. They are condensed into TWO rows (as they were in your original formula) as the pharmaceutical form in 2 of them was "liquid" and in the other was "solution". I decided not to fiddle with that...

    Anything else??

  13. #13
    Registered User
    Join Date
    11-23-2022
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    Hi Glenn! Thank you so much for the update. It's certainly getting there! These are just some things I noticed while I was fiddling with the data:

    Yes, I would leave duplicate pharmaceutical forms the same, as this is how the multiple routes of administration are separated (e.g., IM, IV) in the table. Your formula uses the AIC to select a drug... I tried that previously, and unfortunately, it does miss capturing all the drugs. The AIC 2429, which are two approved drugs for diphenhydramine (Dormirax 25 and Dormirax 50), wouldn't be caught if only AIC 182 was selected. I also previously tried using the ATC code only, but it still doesn't fully capture everything. I found using the combination of
    Please Login or Register  to view this content.
    works best since it searches for all drugs containing diphenhydramine as the ATC and includes only those that have it as its only active ingredient (Number of AIS). I guess the only thing is the entire Generic Name column for "diphenhydramine" would have to be manually entered afterwards since it won't be retrieving the ATC from the drug table.

    It doesn't look like the DINs and route of administration are separated by commas if there are multiple results. Could that be incorporated into the formula so it's easier to spot the different results?

    There was also the code
    Please Login or Register  to view this content.
    in my previous formula... this would output the DIN so that it is eight digits (adds 1 - 2 leading zeroes to make up eight digits). Could this also be incorporated?

    Lastly, this is something optional since you've already helped and done so much for me! I will eventually be merging side-effect frequency data in my main spreadsheet...most of (if not all) of that data would apply to systemic drugs (e.g., those taken orally or injected vs. applied topically). Would there be a way to sort the results so that all oral medications come first, injectables (intramuscular, intravenous, subcutaneous, etc.), then topical? As seen from my previous post...there are numerous routes of administration... I'll likely need to create a table that will classify all of those routes into whether they are considered systemic or topical drugs. I can definitely make a new post for that at a later time. Just wondered if this would be a possibility down the road

    Thank you again for all your help! Much appreciated

  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 2406
    Posts
    44,662

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    As a result of going down some very long dead-ends, I've spent a LOT of time looking at this already. So I will not adjust more stuff blindly.

    Show me.

    1. Show me in a refreshed sample sheet where the use of AIC 182 does not work. Show me, in the same sheet why solely using the name diphenhydramine would also not work. What about preparations that contain more than one active principal? If they complicate things, include examples and show CLEARLY how they should be handled.


    2. The DINs are separated by carriage returns (see my sheet). I thought it was cleaner looking. If they are one long string in yours, enable text wrapping. It's easy to change to comma-space but check BOTH and tell me what you want.

    3. Padding DINs, easy.

    4. On the revised sample sheet, include a table showing (for - at least - ALL the routes of administration used in the sample sheet), with one route per line, the exact order in which you want them to appear.

  15. #15
    Registered User
    Join Date
    11-23-2022
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    Hi, I modified the formula so that it searches for ATC and the number of AIS. If it was only searching for AIC 182, it would be missing DIN 02246449 and 02246450. I attached the revised sample data to this post. I prefer comma-separated values since it's how all my data is currently formatted. If padding the DINs to 8 digits could be incorporated, that would be great. In the revised sample, I added a sheet for expected results, which includes an idea of how route of admin would be preferably ordered/displayed. I added two extra rows as examples only (not on the DPD table). Essentially, I would like the data to display oral formulations as a priority, then injectables (intramuscular > subcutaneous > Intravenous), then topical last
    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 2406
    Posts
    44,662

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    V3. I think that's it all covered.
    Attached Files Attached Files

  17. #17
    Registered User
    Join Date
    11-23-2022
    Location
    Canada
    MS-Off Ver
    Office 365
    Posts
    9

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    Hi Glenn! The formula looks good and is exactly what I need... however, I tried transferring it to my main spreadsheet, and it just froze up my computer. I'm wondering if because it's trying to sift through 38K rows...
    Last edited by steelrends; 11-29-2022 at 04:45 AM.

  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 2406
    Posts
    44,662

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    That's a lot of rows! The obvious suggestion is to split the initial search to return the drug into a separate table on a separate sheet (which can be hidden, if desired) and then do all the fancy stuff usng formulae which don't attempt to store ALL 17K rows. See amended file.

    Attachment removed by GK. Slight problem, which I'll look at later...
    Last edited by Glenn Kennedy; 11-29-2022 at 05:15 AM.

  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 2406
    Posts
    44,662

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    Scrap that. The wee ***** have unsorted. Away for a while.

  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 2406
    Posts
    44,662

    Re: Trying to modify a complex formula that outputs a spilled result in multiple columns

    Easy fix. I had accidentally deleted "Oral" from the list of routes...
    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. [SOLVED] MAX per row across columns with dynamically spilled array
    By Marbleking in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-07-2022, 10:45 AM
  2. Two-way Lookup returning multiple text values (Spilled array formula)
    By DWX57 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-18-2022, 12:17 PM
  3. [SOLVED] Turn "spilled" formula result into text in cell
    By TheNewUnion in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-17-2022, 06:13 AM
  4. [SOLVED] Appending more than two Columns using one Dynamic array or spilled formula.
    By kenesuino in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-02-2022, 03:43 AM
  5. Multiple outputs from a formula
    By trf222 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-01-2020, 09:07 AM
  6. [SOLVED] assistance to modify complex formula from reading 30ea to 30
    By JEAN1972 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 12-08-2018, 11:09 PM
  7. Modify this complex formula using IF THEN ELSE
    By sunny17 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-05-2011, 10:44 AM

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