Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How to check consecutive numbers

Hello mates!

 

I have one doubt.

I have this Excel:

JaviF_0-1628687608289.png

So, I want to know if I don't have consecutive numbers.

Something like, if row number is row number - last row number = 1, it's ok. If it's 2, we have a not consecutive number.

Numbers are examples, I could have some message like "Not consecutive!" or something like that.

 

Is there any way to do this?

Just cheking if column has consecutive numbers and knowing where is the "jump".

Thank you so much! 🙂

1 ACCEPTED SOLUTION

@Anonymous Correct, so you would substitute your consequetive number column for the date column. So, like the following:

Column = 
  VAR __Current = [ConsequetiveNumberColumn]
  VAR __Previous = MAXX(FILTER('Table','Table'[ConsequetiveNumberColumn] < EARLIER('Table'[ConsequetiveNumberColumn])),[ConsequetiveNumberColumn])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

5 REPLIES 5
Greg_Deckler
Community Champion
Community Champion

@Anonymous See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler  🙂

Thanks for your answer.

I don't have any Date column... Just the "consecutive" numbers.

 

How could I adapt the DAX to my problem?

Thanks again!

@Anonymous Correct, so you would substitute your consequetive number column for the date column. So, like the following:

Column = 
  VAR __Current = [ConsequetiveNumberColumn]
  VAR __Previous = MAXX(FILTER('Table','Table'[ConsequetiveNumberColumn] < EARLIER('Table'[ConsequetiveNumberColumn])),[ConsequetiveNumberColumn])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Oops, I tried again.

That worked!!! 😄

Thanks mate 🙂

Anonymous
Not applicable

Thanks @Greg_Deckler 🙂

It seems that didn't work:

JaviF_0-1628756984400.png

JaviF_1-1628757034726.png

Var current and EARLIER don't work 😞

First one, the var says that 'Cannot find name' and it exists 100%.

The other one, 'Parameter is not the correct type'.

 

Any idea to solve these?

Thanks! 😄

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.