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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Ian_Farrell
New Member

Cumulative, iterative total for a calculated column

Hi all, 

I have data that I need to do calculations on. I need a cumulative total (fine), but for certain lines in my data I need to use that cumulative total, do a calculation, then include the result of that calculation in that cumulative total so that the next row that needs to do that calculation it is starting with the right value. 

The calculation is a gain/loss on a pool of assets. 

Here's an example:

 

ABCDEFGH

I

J
Row #DateUSDCumulative USDFX rateCAD (C*D)ACB impact (if USD>$0, -F, otherwise, a calc is required)Cumulative ACB after transaction (sum of G)

ACB rate

(H/D)

Gain/loss

1

Jan 1

$100$1001.3$130$130$1301.3N/A
2Jan 2$100$2001$100$100$2301.15N/A
3Jan 3-$50$1501.2-$60-$57.5 ($60 USD * previous ACB rate)172.51.15$2.5 (60-57.5)
4Jan 4$100$2501.5$150$150$322.51.29N/A
5Jan 5-$50$2001-$50-$64.5($50 * 1.29)$2581.29-$14.5 (50-64.5)

 

My issue is that to calculate column G, I need the previous total of H. I can get this for the first gain/loss calc (row 3) using a SUM and EARLIER. But then for row 5, I need to G to include an earlier result of column G - maybe it needs to iterate through, or perhaps have something in a virtual table?

 

Sorry about the formatting. 

At a bit of a loss here, any thoughts would be appreciated

Thanks, 

Ian Farrell

1 REPLY 1
v-jayw-msft
Community Support
Community Support

Hi @Ian_Farrell ,

 

I think column G and H and I have dependencies with each other which is not supported for DAX.
I suggest you try it in Excel.

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.