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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply

Portfolio management: Calculaiton of weight averaged maturities

Hi, I have the task to analyze the evolution of the days to maturity of my portfolio over time.

I have a table with the Cash flows for each instrument as follows 

 

IDINTR IDCF AmountCF Date (dd/mm/yyy)CF Disb. date dd/mm/yyyy)

1

001100,00001/02/202101/01/2021
2001150,00001/03/202101/01/2021
300150,00015/04/202101/01/2021
4001100,00018/04/202101/01/2021
500230,00030/06/202115/02/2021
600270,00030/10/202115/02/2021
7002100,00001/01/202215/02/2021
8002100,00001/01/202315/02/2021
900250,00001/01/202415/02/2021
1000350,00001/02/202001/01/2020
11003100,00001/03/202001/01/2020
1200350,00001/04/202001/01/2020
13004100,00001/01/202101/01/2019
14004100,00001/06/202001/01/2019
15004100,00001/01/201901/01/2019
1600550,00015/02/202215/02/2021
1700550,00015/02/202315/02/2021
18005100,00015/02/202415/02/2021
19005100,00015/02/202515/02/2021

 

My main objective is to prepare a Graph with dates from 2018 to 2025 showing the evolution of the maturity of the porfolio

I have created already the following measures with a date analysis table (table called Query Calendar)

 

Measure of Tenor days over time:
CF tenor days =
Var CFdate = selectedvalue('CF Date (dd/mm/yyy))
Var Analysisdate = selectedvalue('Query Calendar'[Analysis Date])
Var Disbdate = selectedvalue(CF Disb. date dd/mm/yyyy) )
Var AnalysisvsDisbdate = datediff(Analysisdate,Disbdate,DAY)
Var Result = if(datediff(Analysisdate,CFdate,DAY)<0,0,if(AnalysisvsDisbdate>0, 0, datediff(Analysisdate,CFdate,DAY)))
 
// The first condition is that I cannot have negative tenor days
// The second condition is that as loang as the Instrument dibsursement date (CF Disb. date dd/mm/yyyy) is after the Analysis date, the Tenor is zero as the instrument has not existed before
 
Return
Result

 

I then multiply the tenor days x the CF Amount.

I manage to obtain well the tenor graph (tenor changes every daby each cash flow, but now what i need is to add tenor days for each instrument and then also for the portfolio. Ideally I shoud have

 

Tenor for instruments (INTR ID) = Sum (Tenor of each cash flow * Amount of each cash flow) / Total amount of EUR per instrument

 

Tenor of Portfolio = Summ all (Tenors of all cash flows * Amounts of each cash flow) / Total Amount or EUR)

 

Appreicate your help

Alejandro

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Hi Rico,

Thanks for your interest. I have managed to sort this out with the following measures : 

 

var Lastvisibledateanalysis = MAX('Query Calendar'[Date])
var Results =
CALCULATE(
SUMX(DISTINCT( 'DIM DS_CF'[ID]),
 
Var CFdate = CALCULATE( (Selectedvalue('DIM DS_CF'[0003 CF Realized Date])))
Var Analysisdate = CALCULATE( (selectedvalue('Query Calendar'[Date])))
Var Disbdate = CALCULATE( (selectedvalue('DIM DS_CF'[0001 CF Disb date])))
Var ActualEUR = CALCULATE( (selectedvalue('DIM DS_CF'[0004EU2P Principal only payments in EUR (Actual)])))
 
Var AnalysisvsDisbdate = datediff(Analysisdate,Disbdate,DAY)
Var AnalysisCDate = datediff(Analysisdate,CFdate,DAY)
Var ResultTenor = if(datediff(Analysisdate,CFdate,DAY)<0,0,if(AnalysisvsDisbdate>=0, 0, datediff(Analysisdate,CFdate,DAY)))
Var ResultTenorxEUR = ActualEUR * ResultTenor

Var TotalAmEUR = Calculate(sum('DIM DS_CF'[0004EU2 Principal in EUR (Actual)]),'DIM DS_CF'[0003 CF Realized Date]>Lastvisibledateanalysis,'DIM DS_CF'[0001 CF Disb date]<Lastvisibledateanalysis)

Var InstrMat = divide(ResultTenorxEUR,TotalAmEUR,0)
 
// Return ResultTenorxEUR),
Return ResultTenor),
CROSSFILTER('DIM DS_CF'[0003 CF Realized Date],'Realized Dates'[Date],None)
)
Return
Results

View solution in original post

2 REPLIES 2

Hi Rico,

Thanks for your interest. I have managed to sort this out with the following measures : 

 

var Lastvisibledateanalysis = MAX('Query Calendar'[Date])
var Results =
CALCULATE(
SUMX(DISTINCT( 'DIM DS_CF'[ID]),
 
Var CFdate = CALCULATE( (Selectedvalue('DIM DS_CF'[0003 CF Realized Date])))
Var Analysisdate = CALCULATE( (selectedvalue('Query Calendar'[Date])))
Var Disbdate = CALCULATE( (selectedvalue('DIM DS_CF'[0001 CF Disb date])))
Var ActualEUR = CALCULATE( (selectedvalue('DIM DS_CF'[0004EU2P Principal only payments in EUR (Actual)])))
 
Var AnalysisvsDisbdate = datediff(Analysisdate,Disbdate,DAY)
Var AnalysisCDate = datediff(Analysisdate,CFdate,DAY)
Var ResultTenor = if(datediff(Analysisdate,CFdate,DAY)<0,0,if(AnalysisvsDisbdate>=0, 0, datediff(Analysisdate,CFdate,DAY)))
Var ResultTenorxEUR = ActualEUR * ResultTenor

Var TotalAmEUR = Calculate(sum('DIM DS_CF'[0004EU2 Principal in EUR (Actual)]),'DIM DS_CF'[0003 CF Realized Date]>Lastvisibledateanalysis,'DIM DS_CF'[0001 CF Disb date]<Lastvisibledateanalysis)

Var InstrMat = divide(ResultTenorxEUR,TotalAmEUR,0)
 
// Return ResultTenorxEUR),
Return ResultTenor),
CROSSFILTER('DIM DS_CF'[0003 CF Realized Date],'Realized Dates'[Date],None)
)
Return
Results
v-rzhou-msft
Community Support
Community Support

Hi @AlejandroVazque 

What does Analysis date table looks like? Is there any relationship between Analysis data table and the table as above? Your calculate logic is complex. Could you share a sample pbix without sensitive data with us by your Onedrive for Business? And you can show us the result you want by screenshot. This will make it easier for us to understand your requirement.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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