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

View all the Fabric Data Days sessions on demand. View schedule

Reply
Syndicate_Admin
Administrator
Administrator

Calculate difference between two capitals associated with a rut

Hello Community,

I need help calculating the difference between two rows (capital) associated with the SAME rut and document. Each row shows an amount of capital associated with a corresponding date.

Attached information on how I need it to be displayed (I need to get the column in bold):

DocumentRutDateCapitalDif. Capital
1234561234567807-12-202224190
9876545555555524-11-202110000
9901119876543221-01-20196508,970
9901119876543229-05-20196697188,03
9901119876543211-12-20196634-63
9901119876543213-05-20207290656
9901119876543203-12-20207258-32
9901119876543226-05-2021735698
9901119876543205-11-202188661510
9901119876543201-12-20218795-71
9901119876543204-03-20228759-36
9901119876543227-04-20229345586
9901119876543205-07-20229588243
9901119876543206-02-202310136548

Greetings and thank you very much

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@Syndicate_Admin See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thank you very much for your help ... I was trying to do it according to your example and it works for me ... but how could this column calculated based on RUT and Document condition?

This code worked for me, but I need to condition it:

Variation =
VAR _Actual = Hoja1[Capital]
VAR _Previous = MAXX(FILTER(Hoja1,Hoja1[Capital] < _Actual),Hoja1[Capital])
return
(_Actual - _Previous)
Thank you very much dear!

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