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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
jrobertosm
Frequent Visitor

Calculate the last value per group

Hi team,

I need help to return the value of the last item (Doc), group by Contratc.
I created an index column. But I am not able to calculate this last value.

The solution can be in DAX or M language.

 

Base:

ClientContractDocDate_DocValue_DocIndex
Miguel Santos120630D74589601/01/20201501
Miguel Santos120630D54218501/01/20211802
Ana Matos115312D96352115/05/2019801
Ana Matos115312D85295115/05/2020952
Rute Cardoso117689D75214510/02/2019601
Rute Cardoso117689D89635810/08/2019702
Rute Cardoso117689D96574510/02/2020653
Rute Cardoso117689D98732110/08/2020554
Alice Maria174541D55639515/06/2019301
Alice Maria174541D45874115/06/2020352
Alice Maria174541D63285615/06/2021403
Alice Maria256357D95896820/04/20191201
Alice Maria256357D14578920/04/20201252


Final result:

ClientContractDocDate_DocLast_Value_Doc
Miguel Santos120630D54218501/01/2021180
Ana Matos115312D85295115/05/202095
Rute Cardoso117689D98732110/08/202055
Alice Maria174541D63285615/06/202140
Alice Maria256357D14578920/04/2020125

 

Grateful for the help.

1 ACCEPTED SOLUTION
sayaliredij
Super User
Super User

You can use following formule

 

LastAvailableValue =
var last_date = MAX('Table'[Date_Doc])
RETURN
CALCULATE(SUM('Table'[Value_Doc]),'Table'[Date_Doc] = last_date)
 
Thanks,
Sayali
 
If this post helps, then please consider Accept it as the solution to help others find it more quickly.




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

Proud to be a Super User!




View solution in original post

2 REPLIES 2
sayaliredij
Super User
Super User

You can use following formule

 

LastAvailableValue =
var last_date = MAX('Table'[Date_Doc])
RETURN
CALCULATE(SUM('Table'[Value_Doc]),'Table'[Date_Doc] = last_date)
 
Thanks,
Sayali
 
If this post helps, then please consider Accept it as the solution to help others find it more quickly.




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

Proud to be a Super User!




Solved.

Thank`s.

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.