+ Reply to Thread
Results 1 to 53 of 53

Aligning data in different rows to corresponding column

  1. #1
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Aligning data in different rows to corresponding column

    Happy New Year forum members. I am new to the forum, so I apologize if I put my question under the wrong subforum. I hope someone can help me with my query.

    I have a large dataset (over 10,000 isolates {rows}) that I extracted from an online database.
    Several of the resulting columns have data that is comma delimited (see column B in the included sample data file) with lists of different sizes (the data is antibiotic susceptibility profiles if it makes it easier to understand).
    I separated this data into the next columns using DATA --> Text to Columns. Because the data that was separated contained lists with different antibiotics in the profile for each sample, I want to organize it so the same antibiotics for each row are aligned under column headers with the same name. I manually went through the data to add column headers that corresponded to all the antibiotics utilized in the data (see row 1, columns C through BM. FYI- This includes the antibiotic names from the whole dataset, not just the sample data set you have).

    I have manually rearranged the data in rows 2 and 3 for Isolate 1 & 2 to show how I would like the data to look with the susceptibility data for each antibiotic available for an isolate aligned under the Antibiotic name (I plan to remove the antibiotic name from the data cells using the replace function leaving just the letter after the = once the data is properly aligned; e.g. penicillin=R will just say R). Rows 4 through 22 have been separated, but have not been reorganized/aligned. Is there a way to automatically align the data for each isolate into the corresponding column?

    I often take the brute force approach to data organization and manually move things, but this data set is so big I thought I should find out if there is a more efficient and less error-prone way to do this. Thank you in advance for any help you can provide me.

    Sincerely,
    Michele
    Attached Files Attached Files

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

    Re: Aligning data in different rows to corresponding column

    Easy on a PC using FILTERXML, but you're using a Mac, please confirm...
    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
    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,118

    Re: Aligning data in different rows to corresponding column

    How many AMR suffixes are there? S, R, ND, l (Cap I or lower case L?? Which??). Any others???

  4. #4
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    Hi Glenn.
    Yes I am on a Mac at home (where I am now because of a snow day); however, my work computer is a PC.

    Michele

  5. #5
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    There are 4 suffixes- R, S, capital I, and ND.

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

    Re: Aligning data in different rows to corresponding column

    Please check... does your Mac version support TEXTJOIN function?

    Also, what Excel version are you using in work?

  7. #7
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    I do not think it does, Glenn. If I put =TEXTJOIN into a cell it does not recognize it.

    The work computer is Microsoft Office 2019, I think.

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

    Re: Aligning data in different rows to corresponding column

    OK. I HAD it working... for O365. I'll be back shortly with a PC friendly solution.

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

    Re: Aligning data in different rows to corresponding column

    I hit a slight problem.... I just noticed (e.g. isolate 17) contains TWO phenotypes for the same antimicrobial:

    ampicillin-sulbactam=R,ampicillin-sulbactam=S

    This causes a #SPILL error in my Excel version. Ideally... how would you like results like this handled??

    Formula (PC, for Excel 2010 +, but not O365, will do nothing on a Mac...):

    =IFERROR(FILTERXML("<A><B>"&SUBSTITUTE($B2,",","</B><B>")&"</B></A>","//B[contains(., '"&LOWER(C$1)&"="&"')]"),"")

    copied across and down
    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,118

    Re: Aligning data in different rows to corresponding column

    I can make it work as is for O365, but for an earlier version, I need guidance about multi-phenotype antimicrobial sensitivity....

  11. #11
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    Prior to alignment, is it possible to query all the data to combine cells that have more than one phenotype for the same antibiotic within the same isolate? Have it read ampicillin-sulbactam=R,S instead of ampicillin-sulbactam=R,ampicillin-sulbactam=S. Once again I was thinking to do this manually, but if it is possible to do this automatically, that would be awesome. I know that happens in quite a few places in the large dataset.

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

    Re: Aligning data in different rows to corresponding column

    I'll let that suggestion rumble round in the back of my head for a while...

    One failsafe way for your work PC would be to have 4 columns per antibiotic.. one each for S R I and ND. Then it's easy again.

  13. #13
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    I would think 3 should be the maximum number of phenotypes an antibiotic could have (resistant, sensitive, and intermediate). ND (not determined) would be the same as not being listed, so I am not sure why it was included in the online database in the first place. ND entries are not useful, and I plan to eliminate those. I was thinking to combine the data for multiple phenotypes of a single antibiotic, so I could tell which isolates had multiple phenotypes at a glance once I remove the antibiotic names in the data. Ultimately, I am comparing these phenotypic results to the genotypic results from the same isolates.

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

    Re: Aligning data in different rows to corresponding column

    OK. So, is it OK to have 3 columns per antibiotic? One each for S, I and R?

    I'm away for the night, but will finish it in the Spanish morning, if you're agreeable...

  15. #15
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    That would be okay. I can always do some additional "cleaning" of the data once it has all been arranged in a more usable format.

    I won't be able to do anything with the data until tomorrow anyway since I will need to work computer to do this with. I greatly appreciate the help you are giving me!!

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

    Re: Aligning data in different rows to corresponding column

    OK. We can tweak the appearance of this, as required. This one does the "heavy lifting":

    =IFERROR(IF(LEN(FILTERXML("<A><B>"&SUBSTITUTE($B2,",","</B><B>")&"</B></A>","//B[contains(., '"&C$1&"')]"))>0,"X",""),"")

    copied across and down from C2, along with this one in C1 copied across, to generate the header columns:

    =INDEX(Sheet2!$A$1:$A$62,1+INT((COLUMNS($C$1:C1)-1)/3))&INDEX(Sheet2!$C$1:$C$3,1+MOD((COLUMNS($C$1:C$1)-1),3))

    The antibiotic name in row 1 needs to be the same case as it is in column B. Hence, it's all lower case.
    Attached Files Attached Files

  17. #17
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,342

    Re: Aligning data in different rows to corresponding column

    I need guidance about multi-phenotype antimicrobial sensitivity....
    Don't we all?!
    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.

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

    Re: Aligning data in different rows to corresponding column

    Academic polysyllables.... I'm a veterinary drug residue analyst-come-consultant on the EU/global regulatory environment concerning veterinary drug residues and am well used to these terms!!

    I can hear you yawn loudly... even from here.

  19. #19
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,342

    Re: Aligning data in different rows to corresponding column

    Yawn? No, indeed not. I feel much maligned, Mr K. - I have always been and will, I hope, always remain intellectually curious. I like to beat my other half when watching University Challenge.

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

    Re: Aligning data in different rows to corresponding column

    Yawn... 'cos my area is infinitesimally tiny* and totally "under the radar" for 99.99% of people uninvolved in (inter)national trade in food of animal origin. Most people visibly glaze over when I reply to a "What do you do" question!!

    * tiny is entirely appropriate, as we measure ppb and ppt concentrations of drugs in food and either consume or condemn the food based on the results.

  21. #21
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,342

    Re: Aligning data in different rows to corresponding column

    You see, to me, that sounds fascinating, even though my brain is more suited to the arts.

  22. #22
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    Hi Glenn.
    I am at my work computer and it is running Excel 2016, but this still seems to work. I will try it on the larger data set and see how it does. I will let you know.

    I would love to know what is happening at each step so I might be able to use a similar function in the future for a similar problem (if it is not too hard to explain in text).

    Thanks!

  23. #23
    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,118

    Re: Aligning data in different rows to corresponding column

    Sure, no problem. Check that it's OK first. There's no point in explaining something that needs to be changed!!

  24. #24
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    Hi Glenn.
    So a couple of things...
    With the other columns that are in the large data set, I am afraid I may run out of column spaces having multiple columns per antibiotic (I found 3 other phenotype identifiers and several more antibiotics which I have added to the sheet 2 list). I have started going through the larger data set to combine the antibiotic entries that have multiple phenotypes (ampicillin-sulbactam=R/S instead of ampicillin-sulbactam=R,ampicillin-sulbactam=S). This would no longer require multiple columns per anitbiotic, right? So in the data squares instead of X, can we have it display the text after the "=" ? How would this change both of the functions you wrote previously (hopefully easy fix)?

  25. #25
    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,118

    Re: Aligning data in different rows to corresponding column

    Yes, but you have 16,384 columns in Excel... column XFD... so there's plenty of room.

    This is about as automated as you can get... without O365, where you would need just ONE column per antibiotic

    If you need to add more Abiotics, do so.. insert a row wherever needed. If you need to add more phenotypes, do so. I used two Named Ranges (CTRL-F3 to view/edit) which will autoadjust the ranges. I added in R/S as a test phenotype. The formula is copied out to column ZZ. If you need more... drag it further!!

    Any better??
    Attached Files Attached Files

  26. #26
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    Okay, so maybe this will make life easier. I just downloaded Microsoft 365 on my MAC from my institution site (I work at a University). Now how do I do it to get one antibiotic per column?

  27. #27
    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,118

    Re: Aligning data in different rows to corresponding column

    Hahahaha. It won't work on a Mac. I hope the institutional copy was free. FILTERXML only works on PCs. Time to dump the Mac and buy a real machine... not a fashion icon.

  28. #28
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    It was free. My MAC works better for some genomic analysis work I do. Maybe I just need 2 computers.
    It looks as if it is cloud-based, so I should be able to access it from my work PC when I get back into the building (quarantining for possible Covid contact).

    How would you do this using O365 to get one antibiotic per column?

  29. #29
    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,118

    Re: Aligning data in different rows to corresponding column

    Here is an O365 (PC) version that works for me. Same dynamic arrangement for the antibiotics... just insert a row in sheet 2 and type in the name.

    Let me know.

    I'm in a good mood tonight. I've just had my 200th (and final) research paper accepted for publication in Food Chemistry. Woo Hoo! It only took me 42 years since No 1... but I MADE it. Professor D. Glenn Kennedy BSc PhD DSc FRSC CChem can now vanish into comfortable obscurity...
    Attached Files Attached Files

  30. #30
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    Congratulations!! I am no where near 200... well done!!

  31. #31
    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,118

    Re: Aligning data in different rows to corresponding column

    I left full time University/Government employment (and R&D opportunities) to do consultancy work for Big Pharma,(veterinary).. but mainly to travel and have fun 6 years ago... with 198. I never thought I'd make it to that nice round number.

  32. #32
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    Good morning Glenn.
    I came into my work computer this morning to try out the O365 from there. When I open the file from your O365 post, I see the results, but as soon as I click on any cell, all the phenotype data cells disappear (all I see is the comma delimited cells in Column B and the column headers in row 1), so I can't mess around with it to see what it is doing. Also, it will open in Excel 2016 and appears the way I was hoping it would but it opens in protected view; as soon as I enabling editing, the values in the phenotype cells disappears
    Attachment 762249
    I was able to copy and paste the cells in protected view to a new Excel file and the cells remained as the should. So if I get it to work for the full data set, I should be able to capture the results to be opened in a more easy-for-me-to-access version of Excel.

    While I am here, I thought I would try this on the full data set. When I went to the full data set and copied the appropriate formula into the cells for the antibiotic names (=IFERROR(INDEX(Antibiotic,COLUMNS($W$1:W1)),"")) and for the first couple of isolates (after changing =IF(C$1="","",IFERROR(TEXTJOIN(", ",,SUBSTITUTE(FILTERXML("<A><B>"&SUBSTITUTE($B2,",","</B><B>")&"</B></A>","//B[contains(., '"&C$1&"="&"')]"),C$1&"=","")),"")) to =IF(W$1="","",IFERROR(TEXTJOIN(", ",,SUBSTITUTE(FILTERXML("<A><B>"&SUBSTITUTE($V2,",","</B><B>")&"</B></A>","//B[contains(., '"&W$1&"="&"')]"),W$1&"=","")),"")) so they match with the proper cell source (the comma deliminated list column is column V in the full data set and the antibiotic names headers would start in W1)); nothing happened. I have the antibiotic names in sheet 2, but I do not see sheet 2 called up in the formula for the column headers. What am I missing???
    Attached Images Attached Images

  33. #33
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,342

    Re: Aligning data in different rows to corresponding column

    Professor D. Glenn Kennedy BSc PhD DSc FRSC CChem
    LOL! I had you down as a doctor, for sure, but this is even better. Prof it is!

  34. #34
    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,118

    Re: Aligning data in different rows to corresponding column

    Hard to tell without seeing exactly what you have done...

    Did you define the Named Range (Antibiotic) correctly (CTRL-F3) on my sheet:

    =Sheet2!$A$1:INDEX(Sheet2!$A:$A,MATCH("Zzzz",Sheet2!$A:$A))

  35. #35
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    I am sorry, but I am not understanding this. I do not see anything happen when I press CTRL+F3
    I looked up creating and using named ranges so I could hopefully understand this. Following those directions, I highlighted the antibiotic names in sheet 2, went to the Formula Tab to define the name, but I do not see a box for that.
    Leave it to a computer program to make you feel stupid...
    Attached Images Attached Images

  36. #36
    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,118

    Re: Aligning data in different rows to corresponding column

    Ctrl f3
    Paste formula from my last post into box. Name the range Antibiotic
    Save it.
    Done.

  37. #37
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    I had to set the range in Excel 2016 because the web version does not allow it.

    Now my O365 file has the column names but no phenotype data.
    The "heavy lifting" formula does not seem to be working (correcting it for the location of the comma delimited list).
    I am attaching a copy to the file I was using in O365 with the first 20 or so rows of the full data set. I added a amikacin value to the first isolate to see if anything happens.
    Do you see anything wrong (I do not have the formula in the full array, only the first column)?
    Attached Files Attached Files

  38. #38
    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,118

    Re: Aligning data in different rows to corresponding column

    this is still fine for me. I copied the formula over and removed irrelevant bits. Note: as previously, it will not work in 2016... which does not support TEXTJOIN.

    You had not used the formula I gave for the Named range in Post 34. You had used a fixed range... which is fine, but it is NOT dynamic.

    I do not understand what you meant by "the range" in "I had to set the range in Excel 2016 because the web version does not allow it."
    Attached Files Attached Files

  39. #39
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    I don't understand why it works for you but doesn't work for me... maybe this is not actually Office365. I am unable to set ranges in this Web version of Excel, but I was able to do that part in Excel 2016. I saved the file with the range set, then opened that file in the web version of O365 to do the rest.

    I appreciate your help. I am sorry to be taking so much of your time. I guess I need to figure out why my Office365 is not functioning properly.

  40. #40
    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,118

    Re: Aligning data in different rows to corresponding column

    What does it say in the rectangle that appears briefly when you launch your "365"?

    Then...

    File/Account What does it say below the big "Microsoft" just above the mid centre of the page?

  41. #41
    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. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,342

    Re: Aligning data in different rows to corresponding column

    I think the issue here is that there are a few limitations when using Excel 365 in the browser environment: it's not exactly the same as running it on the desktop.

  42. #42
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    I am at home now, but when I launch O365, under FILE--> INFO, one of the options says "Open in desktop app, Use the full functionality of the Excel desktop app" so the problem is likely as AliGW indicated. I just got off the phone with our IT support, and I should have the functionality to install the desktop version of O365 and not just the online version. I will do that tomorrow on the PC, if our predicted snow is not too bad overnight.

  43. #43
    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,118

    Re: Aligning data in different rows to corresponding column

    Fingers crossed!!

  44. #44
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    Good morning Glenn (and forum).
    After some technical issues with Office 365, I was able to run the function/formula successfully on that column of data; as well as a similar column for detected AMR genotypes by changing the the source cell for where the comma separate list was found and the output cells, as well as the named range for the list of genotypes for the column headers. I sincerely appreciate the help you provided me.

    Now that it worked, if you have the time, I would love to know what is happening at each step so I might be able to use a similar function in the future for a similar problem (if it is not too hard to explain in text).

    Once again, thank you so much for your help. Tonight, I will lift my glass to toast you!

    Michele

  45. #45
    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,118

    Re: Aligning data in different rows to corresponding column

    Which formula do you need an explanation for (or is it all of them!!)????

  46. #46
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    Good afternoon.
    I have come across a problem with the way this handled the data. Many of the gene names they used contain a prime (') or double prime (") and I think this caused a problem because none of the computed cells contain data when they should.
    I adapted the formula you provided for the phenotype/AST data to do the genotype data, but the names the program was looking for were a lot simpler for the phenotypes.
    In the attached file (a subset of the data), I have put some of the source data of concern in red type in column R and the corresponding cells showing the lack of data highlighted in yellow (cells BR3, CZ11, CZ12, CZ23, FR2, FR6, FR7, FR14).
    You can see in columns where there are not any ' or " in the gene name, the program was able to perform as expected and reteurn the word COMPLETE.

    Is this fixable? If so, how do I fix the formula?

    Thanks in advance for your help!
    Michele
    Attached Files Attached Files

  47. #47
    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,118

    Re: Aligning data in different rows to corresponding column

    Not quite there yet. Your immediate problem is fixed by the use of:

    =IF(ISERROR(FILTERXML("<A><B>"&SUBSTITUTE(SUBSTITUTE($R2,"'","*"),",","</B><B>")&"</B></A>","//B[contains(., '"&SUBSTITUTE(W$1,"'","*")&"=COMPLETE"&"')]")),"","Cmplt")

    Apostrophes are not permitted in the XPath bit of the formula. So, I replaced them with *... but you don't see any difference. It's all handled by the formula. I then introduced two check columns. Column U measures the number of =COMPLETE substrings in the AMR genotypes list. Column V measures the number of non-blanks cells in the remainder of each row. In a perfecrt world, the two numbers should be the same. They are, apart from BLAOXY and blaPDC... which appear in the genotypes in column R... but are absent from the genotypes list in sheet 2.

    Over to you!!!

    NB. If you need to re-post, you will have to zip the file to upload it.
    Attached Files Attached Files

  48. #48
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    Thanks Glenn.
    This introduces a different problem for the data set. Like the phenotype data, there can be several possibilities after the equals sign (=)... COMPLETE, PARTIAL, MISTRANSLATION, POINT, HMM, PARTIAL_END_OF_CONTIG (instead of S, I, R etc). So instead of returning Cmplt, I need it to return the text after the =. Is it possible to modify the original formula you gave me with the * ? I tried to put in an * where I thought it would go by comparing the 2 formulas but was not successful in returning only what is after the =, but did return the entire text in the comma separated list between the commas such as aac(6*)-29a=COMPLETE in column BS3.

    Original:
    =IF(U$1="","",IFERROR(TEXTJOIN(",",,SUBSTITUTE(FILTERXML("<A><B>"&SUBSTITUTE($R2,",","</B><B>")&"</B></A>","//B[contains(., '"&U$1&"="&"')]"),U$1&"=","")),""))

    Where I thought the * would go:
    =IF(U$1="","",IFERROR(TEXTJOIN(",",,SUBSTITUTE(FILTERXML("<A><B>"&SUBSTITUTE(SUBSTITUTE($R2,"'","*"),",","</B><B>")&"</B></A>","//B[contains(., '"&SUBSTITUTE(U$1,"'","*")&"="&"')]"),U$1&"=","")),""))
    Attached Files Attached Files

  49. #49
    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,118

    Re: Aligning data in different rows to corresponding column

    I have assumed that, unlike the antimicrobial list, the genotypes can only have one value (after the =). This works. I swapped out * for ¦ as (as sure as fate) it will occur for real somewhere. If there are any further issues PLEASE use THIS sheet, complete with my check columns... as that's the only way to verify such a massive block of data.

    ah well, I have learned something new today. ' doesn't work inside XPath 1.0
    Attached Files Attached Files

  50. #50
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    This is working... almost.

    I added the 2 validation columns in my real data set to look for any additional genotypes absent from the gene list and I got a spill error for many of the rows. Looking at column R, I noticed that there are 2 possible values for a genotype where ever this spill error occurred (aadA1=COMPLETE,aadA1=PARTIAL_END_OF_CONTIG in this case). In addition, the values returned for the gene in question returns a spill error rather than putting both values in the cell (such as COMPLETE,PARTIAL_END_OF_CONTIG) which is how the results were before I realized the problem with the ' .

    I copied one of the cells in column R3 from my real data set into your Excel sheet. The corresponding output for this gene would be in cell EK3.
    Attached Files Attached Files

  51. #51
    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,118

    Re: Aligning data in different rows to corresponding column

    OK. It's back in... just a TEXTJOIN. It is OK. I changed the manual shading for conditional formatting to show inequalities between columns U & V (down to end of the blue shaded block).

    Over to you to break it (again)!!
    Attached Files Attached Files

  52. #52
    Registered User
    Join Date
    01-03-2022
    Location
    Maryland, USA
    MS-Off Ver
    Microsoft Excel for Mac 2011
    Posts
    23

    Re: Aligning data in different rows to corresponding column

    Thank you! This is great! I appreciate the validation (before/after check) with the conditional formatting. I put this into the real data sheet and have found some other genotype names that were missing from the list. The formatting easily shows where the discrepancies are and then I can check the genotype list. I wish my computer had more processing power as the file is so big and any small change and it seems to recalculate everything again ( and I have only done the isolates for one organism so far).

  53. #53
    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,118

    Re: Aligning data in different rows to corresponding column

    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.

+ 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. Problem with merging rows and aligning data
    By manbig in forum Excel General
    Replies: 5
    Last Post: 12-10-2021, 05:14 PM
  2. Aligning data from multiple columns on all rows
    By Shoey5 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-05-2015, 12:49 AM
  3. Replies: 5
    Last Post: 04-25-2013, 01:24 AM
  4. Replies: 4
    Last Post: 05-24-2012, 10:03 AM
  5. Replies: 4
    Last Post: 08-20-2010, 02:34 PM
  6. Replies: 23
    Last Post: 08-12-2010, 04:42 PM
  7. Aligning rows of data
    By e abor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-22-2006, 03: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