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

Last Value

Hello,

 

Need to create a calculated column with the last date (dd/mm/yy hh:mm:ss). Is someone able to help?

Thanks

 

As Is.png 

1 ACCEPTED SOLUTION
TomMartens
Super User
Super User

Hey, assuming your table looks like this

The Solution.png

 

and you want to create a Calculated Column "PreviousDateTime" (Calculated Column means your are looking for DAX solution)
then this DAX statement finds the previous DATETTIME value in column "aDateTimeColumn":

PreviousDateTime = 
var currentDateTime = 'FindPreviousDateTime'[aDateTimeColumn]
return
CALCULATE(
    MAXX(
        ALL('FindPreviousDateTime'[aDateTimeColumn])
        ,IF('FindPreviousDateTime'[aDateTimeColumn] < currentDateTime, 'FindPreviousDateTime'[aDateTimeColumn], BLANK())
    )
)

Maybe you will think this code is a little to much, but beeing in a ROW Context of a table (we want to create a CALCULATED COLUMN), this helps to avoid the awkward message "... circular dependency ..." 🙂

 

Hope this helps

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

 

Try this.  I cannot read the title in cell F1.  Assuming it is 4 Marcacao. try this

 

=CALCULATE(MAX(Data[4 Marcacao]),FILTER(Data,Data[4 Marcacao]<EARLIER(Data[4 Marcacao])))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
TomMartens
Super User
Super User

Hey, assuming your table looks like this

The Solution.png

 

and you want to create a Calculated Column "PreviousDateTime" (Calculated Column means your are looking for DAX solution)
then this DAX statement finds the previous DATETTIME value in column "aDateTimeColumn":

PreviousDateTime = 
var currentDateTime = 'FindPreviousDateTime'[aDateTimeColumn]
return
CALCULATE(
    MAXX(
        ALL('FindPreviousDateTime'[aDateTimeColumn])
        ,IF('FindPreviousDateTime'[aDateTimeColumn] < currentDateTime, 'FindPreviousDateTime'[aDateTimeColumn], BLANK())
    )
)

Maybe you will think this code is a little to much, but beeing in a ROW Context of a table (we want to create a CALCULATED COLUMN), this helps to avoid the awkward message "... circular dependency ..." 🙂

 

Hope this helps

Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany
vega
Resolver III
Resolver III

Please try this:

 

 

LastValue = 
VAR curDate = 'Table'[4#MARCACAO]
RETURN
CALCULATE(
    MAX('Table'[4#MARCACAO]),
    ALL('Table'),
    FILTER('Table', 'Table'[4#MARCACAO] < curDate)
)

 

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.