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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote 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
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

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.