r/excel • • Nov 11 '18

Discussion Power Query - A step-by-step example of parsing non-tabular data

Background

It all started about two weeks ago with this post: Should I learn VBA or go straight to Power Query BI?.

'twas a fun - and at times a bit heated - discussion and, at one point, /u/pancak3d argued that:

(...) there are report formats that both VBA and PQ cannot handle

(...)

Mainly things that aren't tabular and gave random junk thrown in. Happens often when you're trying to parse a report that clearly wasn't intended for data analysis

And topped it off with this comment that got me salivating:

Maybe I'll post an example and challenge someone to clean it with PowerQuery

He made good on his promise a week ago: Can this data be parsed with PowerQuery.

I posted a solution and /u/sqylogin expressed interest in seeing a screencast of how I'd done it. So here is a step-by-step reenactment of parsing File 1, in all its unedited beauty, complete with typos, going back to fix mistakes, pausing to answer my wife talking to me etc... I hope you like the captions typed live in Word. I'm too much of a miser to dish out 250 € for Camtasia; maybe if they have a 50% off Black Friday sale...

File 2 is simpler to parse and uses many of the same tricks used for File 1, plus this sh*t takes time, so I'm holding off on recording a video for it for now.

The video

The video shows how I loaded and parsed File 1 starting from scratch. It totals about an hour and ten minutes and is split into four parts available here: Part 1 - Part 2 - Part 3 - Part 4

Other files

The resulting file is slightly different from the one I posted originally, so I'm including it so you can follow along. I'm also including the Word file I was typing into. Both are available on Github in this directory.

Final thought

This is not meant to argue that Power Query is better than VBA. I use both, but since Power Query stepped into my life, I've pretty much stopped using VBA to reformat and aggregate data.

164 Upvotes

50 comments sorted by

View all comments

Show parent comment

1

u/itsnotaboutthecell 119 Nov 12 '18

Every time I think I know even the slightest of something about the M language I learn something that completely flips the script. In my opinion it's possibly the most important language that everyone is sleeping on at the moment. I understand the GUI can do a lot - but I also think that for those willing to take it a step further you can really unlock it's true potential. I went from pounding VBA code like crazy to maybe now writing it 0.01% of the time.

1

u/tirlibibi17 Nov 12 '18

List.Accumulate, arguably the most valuable function you can learn.

1

u/itsnotaboutthecell 119 Nov 12 '18

Once you realize that M doesn't read from top to bottom - you quickly realize that "there is no spoon" and the language really opens itself up to the endless amount of possibilities.