Category Archives: Visualizations

Drawing Homer Simpson

Recently I started exploring the limits of standard charts in Power BI and ended up drawing all sorts of mathematical functions. For the fun of it, I’ve decided to port a famous Homer Simpson-like curve to DAX and was really impressed by the result.

As always, there is no magic involved, just the usual trio:

  1. Prepare some iterator ranges in M
  2. Add some curve functions in DAX
  3. Visualize it 😍

Depending on how you look at this, the final solution can be summarize into 65 LOC = 15 LOC of M + 2*25 LOC of DAX. But check out the curves on those lines.

The M code

The Power Query code necessary for this doodle, generates some ranges that are specific for drawing various parts of the cartoon figure. For convenience all of them are expressed in units of π.

The DAX code

The DAX code is broken down in 2 measure for X and Y coordinates. Each measure performs two steps:

  1. Define a collection of 10 heavily trigonometric functions (fn[index])
  2. Map the curve function fn[index] to a category fn which corresponds to a drawing range iterator

X coordinates measure

Y coordinates measure

The visual

To build the visualization, select the standard Scattered Chart. Add the column i to Details and Play Axis. Then add fn to the Legend. And to finish all off, map X to X Axis and Y to Y axis — DOH!


Select all of the fn ids from the charts’ legend and press play.


The origin

For the curious minds, the functions above were taken from WolframAlpha. Their scientist have written a series of blog posts in which they describe in minute detail the steps required for generating various curves. Start with:

It would be an understatement to I say that everything boils down to a Fast Fourier Transform — but it does 🙂

And finally — here is the original Homer Simpson-like curve: