arithmetic progression

Let’s take a look at something that’s SO easy to calculate today with a simple spreadsheet but was very challenging to calculate in the past.

(post inspired by Eugenia Chen’s wsj article)


Arithmetic Progression

“A sequence in which the numbers increase by the same amount at each step” (source).

Try to calculate this in your head:

Start with 2. Add 4 to it 10 times.

What’s the SUM? What’s the MEDIAN?

These are the values: 2, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42. SUM is 242 and MEDIAN is 22.

Long sequences were very difficult even for mathematicians before calculators and computers.



Sequences in Excel

It’s easy to create sequences in Excel. (Excel file: save to computer and then open).


These are the inputs.


Below is a non dynamic array solution that is backwards compatible.









And finally the calculations:





1 Formula Solution

My solution above contains several steps. Let’s create sequence values from a single formula!

Option A



SEQUENCE is a dynamic array. Requires Office 365 Excel version. TEXTJOIN keeps it from spilling.

Option B


Formula above is an array and requires Control Shift Enter (just not Enter).

Option C


Formula above doesn’t require Control Shift Enter (just Enter). It spills down into the cells below.



Sequences in Power BI

(download my pbix file.)

GENERATESERIES quickly creates a sequence:

Sequencev1 = GENERATESERIES(2,42,4)

Start with a 2, end at 42, intervals of 4. GENERATESERIES creates a table with 1 column.

Below I use variables but it does the same thing as above. So, is it really necessary?

Sequencev2 =
var SeqCount = 11
var SeqInterval = 4
var SeqStart = 2
var Final = GENERATESERIES(SeqStart,SeqCount*SeqInterval-SeqStart,SeqInterval)


Both DAX versions above contain only internal inputs. Could I connect to an input from outside?

After experimenting I created a measure that I referenced when creating a new table.

Here’s the measure:

DistinctProductKeys = DISTINCTCOUNT(FactTable[Product Key])

Here’s the new table that references the measure above:

DynamicSequenceTBL = GENERATESERIES(1,[DistinctProductKeys],1)
If the distinct count changes this viz also updates. GENERATESERIES table function wants 3 single values (start, end, increment). It’s ok for a measure to be the end value. We could use measures for start and increment values as well.



My Dad The Calculator

My dad was really good at math. We would quiz him with multiplication and division questions. He seemed to be able to calculate anything. Hmm…maybe he would also fake some answers knowing that we wouldn’t know the difference.

I don’t think even he could have calculated a simple sum for a long sequence in his head. I bet he would’ve been a big spreadsheet and database fan. I remember that in the mid 1970s my older cousin had a calculator and it was a big deal. Around 1980 I went with my dad to visit his lawyer. He had one of those classic server room computers. I found it fascinating but it probably was less powerful than a smartphone from today.

What’s next? Imagine what things will be like forty years from now. Today’s technology will be ancient.



About Me

My name is Kevin Lehrbass. I live in Markham (near Toronto) Ontario Canada.

I’ve been working with data for almost 20 years now. SQL (various databases), Excel and now Power BI (DAX).

I find it all so interesting that I also have this blog 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *