Home

Grouping columns

%3CLINGO-SUB%20id%3D%22lingo-sub-825521%22%20slang%3D%22en-US%22%3EGrouping%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-825521%22%20slang%3D%22en-US%22%3EHello!%20I%20have%20a%20report%20that%20I%20generate%20at%20work%20that%20lists%20medications%20entered%20by%20various%20providers%20at%20our%20hospital.%20It%20will%20have%20a%20column%20for%20the%20medication%20name%2C%20a%20column%20for%20the%20dose%2C%20and%20a%20column%20for%20the%20name%20of%20the%20provider.%20The%20list%20is%20VERY%20long.%20Is%20there%20a%20way%20to%20automatically%20group%20each%20of%20the%20providers%20prescriptions%3F%20For%20example%2C%20instead%20of%20having%2062%20separate%20rows%20for%20%22Dr.%20Blue%22%2C%20and%20102%20from%20%22Dr.%20White%22%2C%20can%20I%20click%20something%20to%20make%20it%20say%20%22%20Dr.%20Blue-62%22%2C%20%22Dr.%20White-102%22%2C%20and%20then%20click%20to%20expand%20if%20I%20wanted%20to%20see%20the%20individual%20orders%3F%20What%20I%20am%20ultimately%20interested%20in%20is%20a%20quick%20way%20to%20figure%20out%20the%20number%20of%20prescriptions%20entered%20by%20each%20provider.%20There%20are%20a%20lot%20of%20providers%2C%20so%20going%20through%20and%20counting%20manually%20is%20very%20time%20consuming.%20Thanks!%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-825521%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-825577%22%20slang%3D%22en-US%22%3ERe%3A%20Grouping%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-825577%22%20slang%3D%22en-US%22%3E%3CP%3EHello%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F399232%22%20target%3D%22_blank%22%3E%40PharmD%3C%2FA%3E%26nbsp%3B%2C%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWhat%20you%20describe%20can%20be%20easily%20done%20with%20a%20Pivot%20Table.%26nbsp%3B%20Select%20all%20the%20data%2C%20then%20click%20Insert%20%26gt%3B%20Pivot%20table.%20Now%20you%20see%20the%20pivot%20table%20pane.%20Here%2C%20drag%20the%20name%20into%20the%20%22Rows%22%20area%20and%20again%20into%20the%20Values%20area.%26nbsp%3B%20The%20pivot%20table%20will%20now%20show%20the%20count%20of%20each%20individual%20name.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20829px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F128815iC2B876E6912C09C2%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%222019-08-28_09-08-47.png%22%20title%3D%222019-08-28_09-08-47.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-826653%22%20slang%3D%22en-US%22%3ERe%3A%20Grouping%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-826653%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F399232%22%20target%3D%22_blank%22%3E%40PharmD%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20are%20so%20many%20ways%20of%20doing%20this%20Functions%2C%20Pivot%20Tables%2C%20Subtotal%20Tool%2C%20Power%20Query)%3C%2FP%3E%3CP%3EI'm%20going%20to%20show%20you%20a%20simple%20method%3A%3C%2FP%3E%3CP%3EI%20created%20a%20Sample%20File%20with%20Names%20in%20Column%20A%20and%20in%20Column%20F%20I%20have%20a%20Unique%20list%20of%20Names%20(No%20Duplicates)%20and%20the%20Function%20in%20G2%20reads%3A%3CBR%20%2F%3E%3CSTRONG%3E%3DCOUNTIF(%24A%242%3A%24A%24351%2CF2)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EI%20also%20created%20the%20same%20functionality%20with%20a%20drop%20list%20in%20Cell%20I2%20and%20the%20function%20in%20cell%20J2%20combines%20the%20name%20with%20the%20number%20of%20occurences%20as%20follows%3A%3C%2FP%3E%3CP%3E%3CSTRONG%3E%3DI2%26amp%3B%22%20-%22%26amp%3BCOUNTIF(%24A%242%3A%24A%24351%2CI2)%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EPlease%20look%20at%20the%20attached%20file%3C%2FP%3E%3CP%3EHope%20that%20Helps%3C%2FP%3E%3CP%3ENabil%20Mourad%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-827998%22%20slang%3D%22en-US%22%3ERe%3A%20Grouping%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-827998%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F365248%22%20target%3D%22_blank%22%3E%40nabilmourad%3C%2FA%3E%26nbsp%3B%20...%20the%20pivot%20table%20creates%20the%20list%20of%20unique%20names%20dynamically.%20With%20hundreds%20of%20rows%20it%20might%20be%20easy%20to%20miss%20a%20name%20when%20creating%20the%20list%20for%20a%20formula.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-828074%22%20slang%3D%22en-US%22%3ERe%3A%20Grouping%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-828074%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F7724%22%20target%3D%22_blank%22%3E%40Ingeborg%20Hawighorst%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20suspect%20that%2C%20if%20datasets%20are%20sufficiently%20small%20that%20you%20update%20them%20by%20hand%20rather%20than%20importing%20a%20fresh%20query%20from%20an%20external%20source%2C%20the%20modern%20dynamic%20array%20might%20be%20a%20contender.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20new%20functions%20UNIQUE%20and%20SORT%20are%20fast%20and%20reliable%20and%20they%20update%20automatically%20as%20the%20data%20is%20changed.%26nbsp%3B%20The%20SUMIFS%20are%20somewhat%20more%20labour-intensive%20to%20create%20but%20it%20may%20only%20need%20a%20single%20instance%20of%20the%20formula%20to%20spill%20and%20populate%20the%20crosstab%20or%20list%20dynamically.%26nbsp%3B%20To%20home%20in%20on%20a%20specific%20provider%2C%20one%20could%20use%20FILTER%20to%20create%20a%20separate%20output%20table%20rather%20than%20the%20traditional%20worksheet%20filter%20that%20simply%20hides%20much%20of%20the%20source%20data.%26nbsp%3B%20Not%20quite%20as%20slick%20as%20slicers%20though.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20Pivot%20Table%20may%20still%20have%20the%20edge%20but%20it%20is%20no%20longer%20the%20only%20game%20in%20town!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-828341%22%20slang%3D%22en-US%22%3ERe%3A%20Grouping%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-828341%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3E%26nbsp%3BDefinitely!%20Dynamic%20Arrays%20will%20be%20a%20game%20changer%20and%20make%20many%20a%20pivot%20table%20obsolete.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHowever%2C%20I'm%20conscious%20of%20the%20fact%20that%20as%20of%20today%20Dynamic%20Arrays%20are%20still%20only%20available%20to%26nbsp%3Bpeople%20who%20run%20Office%20365%20Insider%20Fast%2C%20so%20I'm%20advising%20the%20solution%20that%20will%20work%20for%20everybody%20right%20now.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-828952%22%20slang%3D%22en-US%22%3ERe%3A%20Grouping%20columns%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-828952%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F399232%22%20target%3D%22_blank%22%3E%40PharmD%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20agree%20with%20all%20what%20was%20mentioned%20in%20the%20thread%3C%2FP%3E%3CP%3EThe%20beauty%20of%20Excel%20is%20the%20availability%20of%20multiple%20techniques%20that%20achieve%20the%20same%20goal.%3CBR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F7724%22%20target%3D%22_blank%22%3E%40Ingeborg%20Hawighorst%3C%2FA%3E%26nbsp%3B%20I%20love%20Pivot%20tables%20but%20I%20did%20not%20mention%20that%20as%20you%20had%20already%20covered%20it%20perfectly.%20On%20the%20other%20hand%20the%20function%20has%20an%20advantage%20over%20Pivot%20Tables%20(If%20the%20list%20of%20names%20is%20unchanged)%20which%20is%20automatically%20updating%20(specially%20if%20I%20use%20it%20with%20a%20Table%20or%20a%20defined%20name%20for%20an%20expandable%20range)%20while%20the%20PT%20requires%20Refreshing%20manually%20(unless%20you%20write%20a%20small%20code%20in%20VBA)%20or%20the%20maximum%20you%20can%20set%20the%20option%20to%20refresh%20on%20Opening%20the%20file.%3C%2FP%3E%3CP%3EI%20also%20agree%20with%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F214174%22%20target%3D%22_blank%22%3E%40Peter%20Bartholomew%3C%2FA%3E%26nbsp%3B%20on%20how%20practical%20Dynamic%20Arrays%20are%20but%2C%20among%20thousands%20of%20students%20I%20teach%20still%20very%20few%20have%20access%20to%20them...%20I%20made%20that%20survey%20just%20yesterday%20when%20I%20was%20introducing%20the%20new%20giant%20function%20XLOOKUP...%3CBR%20%2F%3EThe%20moral%20of%20this%20post%20is...%20This%20is%20a%20wonderful%20community%20we%20all%20help%20each%20other.%3C%2FP%3E%3CP%3Ehave%20a%20great%20day%20everyone%3C%2FP%3E%3CP%3ENabil%20Mourad%3C%2FP%3E%3C%2FLINGO-BODY%3E
PharmD
Occasional Visitor
Hello! I have a report that I generate at work that lists medications entered by various providers at our hospital. It will have a column for the medication name, a column for the dose, and a column for the name of the provider. The list is VERY long. Is there a way to automatically group each of the providers prescriptions? For example, instead of having 62 separate rows for "Dr. Blue", and 102 from "Dr. White", can I click something to make it say " Dr. Blue-62", "Dr. White-102", and then click to expand if I wanted to see the individual orders? What I am ultimately interested in is a quick way to figure out the number of prescriptions entered by each provider. There are a lot of providers, so going through and counting manually is very time consuming. Thanks!
6 Replies

Hello @PharmD , 

What you describe can be easily done with a Pivot Table.  Select all the data, then click Insert > Pivot table. Now you see the pivot table pane. Here, drag the name into the "Rows" area and again into the Values area.  The pivot table will now show the count of each individual name.

 

2019-08-28_09-08-47.png

 

 

@PharmD 

There are so many ways of doing this Functions, Pivot Tables, Subtotal Tool, Power Query)

I'm going to show you a simple method:

I created a Sample File with Names in Column A and in Column F I have a Unique list of Names (No Duplicates) and the Function in G2 reads:
=COUNTIF($A$2:$A$351,F2)

I also created the same functionality with a drop list in Cell I2 and the function in cell J2 combines the name with the number of occurences as follows:

=I2&" -"&COUNTIF($A$2:$A$351,I2)

Please look at the attached file

Hope that Helps

Nabil Mourad

 

@nabilmourad  ... the pivot table creates the list of unique names dynamically. With hundreds of rows it might be easy to miss a name when creating the list for a formula.

@Ingeborg Hawighorst 

I suspect that, if datasets are sufficiently small that you update them by hand rather than importing a fresh query from an external source, the modern dynamic array might be a contender. 

 

The new functions UNIQUE and SORT are fast and reliable and they update automatically as the data is changed.  The SUMIFS are somewhat more labour-intensive to create but it may only need a single instance of the formula to spill and populate the crosstab or list dynamically.  To home in on a specific provider, one could use FILTER to create a separate output table rather than the traditional worksheet filter that simply hides much of the source data.  Not quite as slick as slicers though.

 

The Pivot Table may still have the edge but it is no longer the only game in town!

 

 

@Peter Bartholomew Definitely! Dynamic Arrays will be a game changer and make many a pivot table obsolete.

 

However, I'm conscious of the fact that as of today Dynamic Arrays are still only available to people who run Office 365 Insider Fast, so I'm advising the solution that will work for everybody right now.

@PharmD 

I agree with all what was mentioned in the thread

The beauty of Excel is the availability of multiple techniques that achieve the same goal.
@Ingeborg Hawighorst  I love Pivot tables but I did not mention that as you had already covered it perfectly. On the other hand the function has an advantage over Pivot Tables (If the list of names is unchanged) which is automatically updating (specially if I use it with a Table or a defined name for an expandable range) while the PT requires Refreshing manually (unless you write a small code in VBA) or the maximum you can set the option to refresh on Opening the file.

I also agree with @Peter Bartholomew  on how practical Dynamic Arrays are but, among thousands of students I teach still very few have access to them... I made that survey just yesterday when I was introducing the new giant function XLOOKUP...
The moral of this post is... This is a wonderful community we all help each other.

have a great day everyone

Nabil Mourad

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
35 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
9 Replies