We all know that Pivot Tables are best thing since avocado on toast. But they can’t slice text values and spread them in a table with Pivots. So how to take a large blob of text and turn it in to something meaningful like below?
Simple, we use Power Query.
How to pivot text values – Tutorial
- Let’s say your large chunk of meaty data is in a table named text
- Select any cell in your table and go to Data > From Table (or Power Query > From Table)
- Once your data is in PQ, split it by : (right click on the column and choose split column by > Delimiter)
- Now, your data will become 2 columns. First column with FUNxxx reference and next column with rest of the text.
- Go to second column and remove nulls (Filter > uncheck nulls)
- Now replace all punctuation in second column using replace values
- Replace ( ) , with spaces
- Now split column 2 by delimiter = space. But this time, split in to rows (using advanced option as shown below)
- Filter the rows on second column so you only have anything that begins with FUN or REQ
- Select both columns and remove duplicates
- Rename columns and load your data to Excel.
- Done, your text is now pivoted.
Related: Introduction to Power Query
Pivoting Text Values – Video Tutorial
If the Power Query steps seem confusing, watch below quick video tutorial to understand how to pivot text values in Excel. You can also catch this on Chandoo.org YouTube Channel.
Download Text Value Pivot – Example workbook
Click here to download example workbook with the query steps. Go to Pivot tab and right click on the table to either refresh or edit.
Got few more minutes? Check out other awesome ways to use Power Query
If you have just 10 minutes to learn, I suggest spending that on below PQ tips. You will learn powerful new ways to deal with data pains.
- Figuring out Employee Churn with Power Query [HR Analytics]
- Rescue oddly shaped data – Battle between Formulas, VBA and Power Query
- Extract currency amounts from text – Power Query Tutorial
- Unpivot data quickly with Power Query [tutorial]
Got a pesky text extraction / summary problem – post here
If you struggle processing text and want to learn new ways to deal with it, post your problem in comments. I will try to share solutions thru Excel / Power Query.
Alternatively, feel free to suggest your own methods to pivot text values in Excel.
My name is Chandoo. Thanks for dropping by. My mission is to make you awesome in Excel & your work. I live in Wellington, New Zealand. When I am not F9ing my formulas, I cycle, cook or play lego with my kids. Know more about me.
Thank you and see you around.
Leave a Reply
|« Time series analysis and interactive forecasting in Excel – Sample video from 50 ways course||35 shortcuts & tricks to make you an #AWESOME Data Analyst »|