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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
StepanResl
Frequent Visitor

Recursive Calculation of Table

Hey,

I have table like this with columns Year, Month, Person, Static (Costs) and Revenue. I am trying to find out, how to provide last column inside Power BI. In column header I wrote Excel Formula with some pseudo code B(x-1)..., which is normaly working inside Excel.  Can someone help me please to provide this inside Power BI?

Poznámka 2020-04-08 102336.png

 

6 REPLIES 6
v-lionel-msft
Community Support
Community Support

Hi @StepanResl ,

 

I can't understand your pseudocode, can you give an example? For example,  how was the first line calculated?

kkk1.PNG

 

Best regards,
Lionel Chen

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

Hey @v-lionel-msft ,

 

it works like:

(SUM value from same column (where were are calculating this), where we are still talking about same Person as in actual calculating row but with (Month - 1)) + (Value from column Revenue (in actual row) - Value from column Static (in actual row)) if result is lower then 0, then result should be zero.



Poznámka 2020-04-09 083554.png

 

Hi @StepanResl ,

 

1. Add an [Index] column manually.

lll14.PNG

2. Create measures.

 

Measure 2 = 
VAR x = 
MAX(Sheet5[Revenue]) - MAX(Sheet5[Static]) 
RETURN
IF(
    x <0,
    0,
    x
)

Measure 3 = 
CALCULATE(
    [Measure 2],
    FILTER(
        ALLSELECTED(Sheet5),
        Sheet5[Index] = MAX(Sheet5[Index]) - 1 && Sheet5[Person] = MAX(Sheet5[Person])
    )
)

 

 

3. Create a measure again

 

Calculation = 
VAR x = MAX(Sheet5[Revenue]) - MAX(Sheet5[Static])
RETURN
x + [Measure 3]

 

lll15.PNG

Although my data is the same as yours, but I started taking values from October 2017, so the returned results are different.

 

Best regards,
Lionel Chen

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

 

Hey,

 

thank you for your help, but unfortunately it isnt calculated right. In your Third row should be 1200 and then in fourth should be 1200+500 = 1700.

 

But thank you for your help. I am trying it same way, but i cannt figurite out, how to provide right results.

 

Kind Regards,

Steve

Anonymous
Not applicable

Hi @StepanResl.

Please do not try to squeeze a round peg into a square hole or... the other way round.

Use Power Query for this as this is the right tool, not DAX.

Best
D
Greg_Deckler
Community Champion
Community Champion

It's not really clear what you are doing here but if you are trying to do true recursion in DAX, you can't. https://www.linkedin.com/pulse/previous-value-recursion-dax-greg-deckler-microsoft-mvp-/



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors