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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request 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
Solution Sage
Solution Sage

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
Solution Sage
Solution Sage

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors