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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.