Skip to main content
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

Frequent Visitor

Recursion/Self referencing & year-to-date attribution effect

Hello Fabric Community,

I hope you're all doing well! I'm currently working on a project where I need to calculate the year-to-date cumulative attribution effect for investment portfolio analysis in Power BI, and I've encountered a bit of a roadblock.

Here's a breakdown of the problem:

I have a formula that calculates the Year-to-date cumulative attribution effect:

Ei' = (Ei-1')(1+BRi/100) + (Ei)(1+PRi-1'/100)


  • Ei' is the cumulative attribution effect through period i.
  • Ei-1' is the cumulative attribution effect in period i-1.
  • BRi is the benchmark return in period i.
  • Ei is the attribution effect in period i.
  • PRi-1' is the cumulative portfolio return through period i-1.

Note that on the 1st of January no historical data should be used in this formula (even though the dataset contains data from multiple years):

Ei' = (0)(1+BRi/100) + (Ei)(1+0/100)

Thus on January 1st:

Ei' = Ei

I find it difficult to implement the logic correctly, particularly the self-referencing. I read in other posts that a work-around for self-referencing in formulas is to make the formula closed-form. Could anyone provide guidance on the possibility of making this formula closed form and if possible, how to write a code for this formula that works in DAX?

Below you find some sample data and in column G the excel calculation for this formula.

1 DatePort. Total ReturnCumu. Port. Total ReturnBench. Total ReturnAttribution effectCumulative attribution effectExcel formula

Note that column G contains the excel formulas I use to calculate column F. I want to replicate the results in column F by dax code.

Any insights or suggestions would be greatly appreciated!


Thank you in advance for your help.

Community Support
Community Support

Hi @JoeriT ,

I create a table as you mentioned.


Then I create a column and here is the DAX code.

Column =
VAR CurrentDate = 'Table'[Date]
VAR CurrentAttributionEffect = 'Table'[Attribution effect]
VAR CurrentBenchmarkReturn = 'Table'[Bench. Total Return]
VAR CurrentPortfolioReturn = 'Table'[Cumu. Port. Total Return]
VAR PreviousCumulativeAttributionEffect =
        SUMX (
            FILTER ( ALL ( 'Table' ), 'Table'[Date] < CurrentDate ),
            'Table'[Cumulative attribution effect]
        ALL ( 'Table' )
    IF (
        CurrentDate = DATE ( YEAR ( CurrentDate ), 1, 1 ),
        PreviousCumulativeAttributionEffect * ( 1 + CurrentBenchmarkReturn / 100 ) + CurrentAttributionEffect * ( 1 + CurrentPortfolioReturn / 100 )

Finally you can get what you want.





Best Regards

Yilong Zhou

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

Hi @v-yilong-msft 

Thank you for your reply.


My apologies. I did not include the row numbers in the sample data. I edited this now. Column G is just to clarify how I calculate Column F. I want to write a dax code that calculates Column F. 

Helpful resources

July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

July Newsletter

Fabric Community Update - July 2024

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

Top Solution Authors