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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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