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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
alvaro_miranda
Frequent Visitor

Cumulative Time Weighted Rate of Return

Hi,

 I'm trying to build a chart like this

 

pantalla-desktop-plataforma-1-1536x669.png
And i'm using the calculations made by @OwenAuger  at Time-Weighted Return and Money-Weighted Return – Owen Auger's BI Blog (owenaugerbi.com)

This is what i need to calculate for each day until the last

alvaro_miranda_1-1725552950947.png

 


The issue is that the correct TWR (Time-Weighted Return) value is only given at the total level of the selected period, but I'm unable to calculate the cumulative value. Could someone help me with these calculations? You can find the dashboard link in the message I shared earlier.



5 REPLIES 5
alvaro_miranda
Frequent Visitor

Here's a sample data where the bold columns are from database

 

CuentaDateValue OpenCashflowValue CloseDaily ReturnTWR
101-01-20242523751$0$2.523.807,340,00%0%
102-01-20242523807$0$2.525.654,860,07%0,070%
103-01-20242525655$0$2.532.308,650,26%0,330%
104-01-20242532309$0$2.530.964,91-0,05%0,280%
105-01-20242530965$0$2.530.438,70-0,02%0,260%
106-01-20242530439$0$2.530.479,700,00%0,260%
107-01-20242530480$0$2.530.518,700,00%0,260%
108-01-20242530519$0$2.517.846,80-0,50%-0,241%
109-01-20242517847$0$2.490.197,86-1,10%-1,339%
110-01-20242490198$0$2.492.815,650,11%-1,230%
111-01-20242492816$0$2.528.635,071,44%0,192%
112-01-20242528635$0$2.516.607,50-0,48%-0,289%
113-01-20242516608$0$2.516.603,500,00%-0,289%
114-01-20242516604$0$2.516.591,410,00%-0,289%
115-01-20242516591$0$2.510.388,94-0,25%-0,538%
116-01-20242510389$0$2.559.804,491,97%1,421%
117-01-20242559804$0$2.540.929,49-0,74%0,671%
118-01-20242540929$0$2.521.969,35-0,75%-0,084%
119-01-20242521969$0$2.510.432,34-0,46%-0,544%
120-01-20242510432$0$2.510.419,230,00%-0,544%
121-01-20242510419$0$2.510.416,230,00%-0,544%
122-01-20242510416$0$2.522.545,940,48%-0,066%
123-01-20242522546$0$2.494.020,60-1,13%-1,196%
124-01-20242494021$0$2.565.106,742,85%1,620%
125-01-20242565107$0$2.564.658,42-0,02%1,600%
126-01-20242564658$0$2.584.099,950,76%2,372%
127-01-20242584100$0$2.584.095,950,00%2,372%
128-01-20242584096$0$2.584.080,780,00%2,372%
129-01-20242584081$0$2.605.192,920,82%3,212%
130-01-20242605193$0$2.606.311,090,04%3,253%
131-01-20242606311$0$2.604.802,06-0,06%3,191%


TWR is 

 

Time-Weighted Return (non annualized) = 
PRODUCTX (
    'Calendario',
    DIVIDE ( [Value Close Total] - [Cashflow Total], [Value Open Total] )
)
    - 1
Value Close Total = SUM(Patrimonios[Value Close])
Value Open Total = SUM(Patrimonios[Value Open])
Cashflow Total = SUM(Patrimonios[Giros y Abonos Netos])

 

all my data has the structure to use this
Time-Weighted Return and Money-Weighted Return – Owen Auger's BI Blog (owenaugerbi.com)
As I said the hart part is forcing the TWR to be zero when it's the first date in the context and then every other row is calculated as TWR(t) = (1+TWR(t-1))*(1+Return(t)) - 1
this will lead in this chart

alvaro_miranda_0-1725568939625.png

 






You've already got a daily return column. Just link those together with a classic cumulative pattern like this:

 

VAR _CurrDate = MAX ( 'Calendario'[Date] )
VAR _Dates_ =
    FILTER ( ALLSELECTED ( 'Calendario' ), 'Calendario'[Date] <= _CurrDate )
VAR _Product =
    PRODUCTX (
        _Dates_,
        1 + CALCULATE ( SELECTEDVALUE ( Patrimonios[Daily Return] ) )
    )
VAR _Result =
    IF ( ISBLANK ( _Product ), BLANK (), _Product - 1 )
RETURN
    _Result

 

AlexisOlson_0-1725575371147.png

 

Wow, it almost works as I expected. I want it to start at 0, and then the second row should recognize that the first value is 0. I implemented your measure, and this is what I got.

alvaro_miranda_1-1725633161849.png

 

I don't understand why you'd want to ignore the return for the first day, but you could filter the _Dates_ table to remove the row with the minimal date.

AlexisOlson
Super User
Super User

I do this sort of calculation all the time. Can you share specific data and expected return? I didn't "find the dashboard link in the message I shared earlier".

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

 

 

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.