cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
astojanac
Helper II
Helper II

DAX: Help with dynamic calculated column

Hi all, 

 

I'm dealing with the problem of using the calculated value from the previous row in the current row.


My example and Excel output file are at the link below:

 

https://drive.google.com/drive/folders/1QPtIREy36SoVdkdxPimng3-nIpqRHb6Q?usp=sharing

 

I made 2 columns (Closing and Closing 2) but there's a little difference from what I acctualy need. 

 

Regards

 

I appriciate any help or hint!

 

1 ACCEPTED SOLUTION

Hi @astojanac,

It sounds like multiple aggregate requirements, you can try to add a variable with summarize function to apply the first aggregation then use the iterator function with that variable to enable another aggregation.

All the secrets of SUMMARIZE - SQLBI

Measure Totals, The Final Word 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

@astojanac 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


@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop!
Microsoft Hates Greg's Quick Measures
Check out my latest book!

Hi @Greg_Deckler ,

 

Thanks a lot for the answer, but unfortunately I can't find way out with this kind of formula.

My formula returns nicely, however the problem is that it does not calculate interest on every amount but collects all payments and then calculates interest. Is there a chance you can help me overcome this problem?

 

Thanks in advance!

Hi @astojanac,

It sounds like multiple aggregate requirements, you can try to add a variable with summarize function to apply the first aggregation then use the iterator function with that variable to enable another aggregation.

All the secrets of SUMMARIZE - SQLBI

Measure Totals, The Final Word 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!