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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
AdamPBIDev
Regular Visitor

Recursive Dax Calculation

Dear Dax Gurus,

 

Would appreciate some help - I'm looking to create a calculated column forecast which at index 0 simply takes the (Activity + (Activity * Activity Change %)), but for all other indexes takes the previous row calculated forecast and applies the current row activity change %. 

Note the index resets at each change in (Cost Centre)"Code".

 

Screenshot 1

Question 3.png

 

Sample Data

 

Month YearCodeActivity Change %ActivityIndexForecast Formula
01/03/20221002.0%304803108 =D2+(D2*C2)
01/04/2022100-4.0% 12984 =F2+(F2*C3)
01/05/20221005.0% 23134  
01/06/20221007.0% 33353  
01/07/2022100-4.0% 43219  
01/08/20221008.0% 53476  
01/09/2022100-3.0% 63371  
01/10/20221002.0% 73439  
01/11/20221004.0% 83576  
01/12/2022100-6.0% 93363  
01/03/20222001.7%344803506 =D12+(D12*C12)
01/04/2022200-3.4% 13387 =F12+(F12*C13)
01/05/20222004.2% 23530  
01/06/20222005.9% 33739  
01/07/2022200-3.4% 43611  
01/08/20222006.8% 53857  
01/09/2022200-2.6% 63757  
01/10/20222001.7% 73822  
01/11/20222003.4% 83952  
01/12/2022200-5.2% 93749  

 

I did try Gerhard Brueckl's interesting approach for creating this entirely in DAX Link  but unfortunately I couldn't get this to work at Cost Centre Code level (works perfectly at an overall level) so have gone down the path of creating the above table instead

 

Thanks in advance

Adam

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @AdamPBIDev,

AFAIK, current power bi data model tables do not include row and column index AND DAX expression does not support doing recursive calculations.

Previous Value (“Recursion”) in DAX - Microsoft Power BI Community

You can enter to query editor to do these calculations but it will be poor performance on recursive calculations.

Recursive Functions in Power BI / Power Query — The Power User
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @AdamPBIDev,

AFAIK, current power bi data model tables do not include row and column index AND DAX expression does not support doing recursive calculations.

Previous Value (“Recursion”) in DAX - Microsoft Power BI Community

You can enter to query editor to do these calculations but it will be poor performance on recursive calculations.

Recursive Functions in Power BI / Power Query — The Power User
Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
amitchandak
Super User
Super User

@AdamPBIDev , Try a new column,

 

Value = MAXX(filter(Data, [Index] =0 && [Code] =EARLIER(Data[Code])),[Activity])* PRODUCTX(Filter(DATA, [Code] =EARLIER(Data[Code]) && [Index]  <=EARLIER(Data[Index])), 1+[Activity Change %])

 

File attached after signature

 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors