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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
adin
Helper I
Helper I

Modelling future cashflows using GENERATESERIES

I'm trying to convert an old financial model that was built in excel (using macros and hence running slow) into power bi.

 

I'm trying to model future cash flows for each loan in my dataset but am struggling to figure how to use generate series along with calculations (in measure) in order to execute each calc per loan per future period. the ultimate end result is i want to be able to slice and dice the numbers not just have one aggregate total 

 

I managed to work out the logic to calculate future loan value based on runoff rate I look up in a reference table, but now am stuck because the formula only works for one loan (i.e. only when i filter one loan at a time) . the formula for the projected future loan value is below along with a screenshot of the output filtered for only one loan. When I remove the filter the measure breaks.

 

the result I'm after is the total value of all loans at each future period. 

 

FuturePeriods = GENERATESERIES(0,132,1)
RunOffRate = 

var FuturePeriodsTable = CROSSJOIN(NetPresentValueData,FuturePeriods)

Var Loan_duration = SUMX(FuturePeriodsTable,NetPresentValueData[Tenure_months] + FuturePeriods[FuturePeriod])

Var DurationCutOffLookup = CALCULATE(max(RunOffRates[DurationBand CutOff]),RunOffRates[DurationBand CutOff]<=Loan_duration)

Return

if(SELECTEDVALUE(FuturePeriods[FuturePeriod]) = 0, 0,

SWITCH(SELECTEDVALUE(NetPresentValueData[GroupId]),

"Group1", LOOKUPVALUE(RunOffRates[group1],RunOffRates[DurationBand CutOff],DurationCutOffLookup)/12,

"Group2", LOOKUPVALUE(RunOffRates[group2],RunOffRates[DurationBand CutOff],DurationCutOffLookup)/12

))

 

Projected Balance = 

VAR OriginalBalance = MAX(NetPresentValueData[Total_current_balance])

VAR __d = MAX ( FuturePeriods[FuturePeriod] )

RETURN

OriginalBalance * CALCULATE ( PRODUCTX(FuturePeriods, (1 - 'Measures Table'[RunOffRate]) ), ALLSELECTED (FuturePeriods), FuturePeriods[FuturePeriod] <= __d )

Screenshot 2022-01-12 082500.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Having difficulty working with iterator functions, which is what I'm assuming this needs 

 

Thanks for any help you can provide

 

2 REPLIES 2
v-jayw-msft
Community Support
Community Support

Hi @adin ,

 

Have difficult to follow. Please take a look at the topic about How-to-Get-Your-Question-Answered-Quickly .

Also please share the logic of your formula and which SELECTEDVALUE function is you mentioned above.

 

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.
adin
Helper I
Helper I

i think the error is when i use the SELECTEDVALUE function, but I can not figure how to do it without it 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.