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:


3 thoughts on “Drawing Homer Simpson

  1. that’s funny : ) how should I paste the m code into power query? should I convert it to list or table? should I rename it to homer or what? I couldnt create the pbix file.


    1. You’re on the right path.
      Copy the m code into power query editor. Make sure to replace all the wrapper code there. Rename the query to “Homer”. And add the DAX code as measure to this Homer table. After replicating the setup as in the scatter chart you should see the Homer’s dotted figure. If you want to replicate the animation, select all of the fn values from the legend (values 0..9), now slide the play axis and you should see the figure as being drawn.


      1. Hi there! Thanks for this article, that’s really awesome!
        But i can’t replicate the animation with lines, just dots which moving. Could you please write about lines with more detailes?


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s