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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
petersoelberg
Frequent Visitor

Calculated colum - latest version of document

Hi! I have been searching for a similar case for a couple of days but I am unable to find a relatable solution so I hope one of you will be abe to help me with my enquiry. 

 

I have a sales order archive, where i only want to use the data from the latest version of the document. 

I hope the following data will illustate the data model - I want to create a calculated column (Like i have manually created in the example below) which I can filter, so i only see the latest version. (There are more columns to the data model, i just haven't presented it - but that is why I only want to view the latest entry..)

 

Document noVersion no.Calculated Column!
MO00055991Archived
MO00055992Archived
MO00055993Archived
MO00055994Archived
MO00055995Archived
MO00055996Archived
MO00055997Latest
MO00032341Latest
MO00032211Archived
MO00032212Archived
MO00032213Archived
MO00032214Latest
MO00074721Archived
MO00074722Archived
MO00074723Archived
MO00074724Latest
1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@petersoelberg - This is basic use of EARLIER:

Column =
  VAR __Max = MAXX(FILTER('Table',[Document no] = EARLIER([Document no])),[Version no])
RETURN
  IF([Version no] = __Max,"Latest","Archived")

For more complex versions, 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/3395...



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
Anonymous
Not applicable

@petersoelberg 

You could just use Allexcept(): 

 

Column = 
var maxversion = CALCULATE(MAX('Table'[Version no.]),ALLEXCEPT('Table','Table'[Document no]))
Return IF([Version no.]=maxversion,"Latest","Archived")

 

allexcept.JPG

 

Paul Zheng _ Community Support Team
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@petersoelberg , Refer on of the two. My favorite is LASTNONBLANKVALUE these days

new Column = if(Table1[Version no.]= LASTNONBLANKVALUE(Table1[Document no],max(Table1[Version no.])),"Latest","Archived")
new Column =
  if([Version no] = maxx(filter(Table,[Document no] = earlier([Document no])),[Version no]),"Latest","Archived")

 

Please Watch/Like/Share My webinar on Time Intelligence: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-Y...
My Youtube Tips at: https://www.youtube.com/playlist?list=PLPaNVDMhUXGYrm5rm6ME6rjzKGSvT9Jmy

Appreciate your Kudos.

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Community Champion
Community Champion

@petersoelberg - This is basic use of EARLIER:

Column =
  VAR __Max = MAXX(FILTER('Table',[Document no] = EARLIER([Document no])),[Version no])
RETURN
  IF([Version no] = __Max,"Latest","Archived")

For more complex versions, 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/3395...



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...

Thank you very much Greg! This really solved my issue. 

camargos88
Community Champion
Community Champion

Hi @petersoelberg ,

 

Try this code:

 

Column =
VAR _maxVersion = CALCULATE(MAX('Table'[Version no.]), FILTER('Table', 'Table'[Document no] = EARLIER('Table'[Document no])))
RETURN IF('Table'[Version no.] = _maxVersion, "Latest", "Archived")
 
Capture.PNG
 
 


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.