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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
OscarSuarez10
Helper III
Helper III

Payback calculation

Hello i have to calculate the payback period per TEST and ID  using the following equation (usgin DAX):

 

PayBack = Last year with negative accumulated cash flow  +  (absolute value of the last negative accumulated cash flow / cash flow value in the following period)

 

The data is in the following table:

IDTESTYEARCASH FLOWACCUMULATED CASH FLOW
011-5.446.900,00-$ 44.963.300,00
01248.374.800,00$ 67.583.600,00
01334.778.600,00$ 143.859.400,00
01424.837.100,00$ 192.896.790,00
01515.513.500,00$ 217.445.668,00
0167.799.090,00$ 223.557.968,00
1021-5.418.360,00-$ 44.933.160,00
102248.228.600,00$ 67.559.840,00
102335.021.100,00$ 144.020.240,00
102424.933.700,00$ 193.430.310,00
102515.350.400,00$ 217.839.289,00

 

Payback:  TEST 1 ID 0 = 1.93 years

                TEST 2 ID 10 = 1.93 years 

 

 

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

Hi @OscarSuarez10 

Measure = 
VAR Year_ = CALCULATE(MAX(Table1[YEAR]);Table1[ACCUMULATED CASH FLOW] < 0)
VAR Numerator_ = CALCULATE(DISTINCT(Table1[ACCUMULATED CASH FLOW]);Table1[YEAR] = Year_) 
VAR YearNext_ = CALCULATE(MIN(Table1[YEAR]);Table1[YEAR] > Year_)
VAR Denominator_ = CALCULATE(DISTINCT(Table1[CASH FLOW]);Table1[YEAR] = YearNext_)
RETURN
Year_ + DIVIDE(Numerator_; Denominator_)

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

View solution in original post

1 REPLY 1
AlB
Community Champion
Community Champion

Hi @OscarSuarez10 

Measure = 
VAR Year_ = CALCULATE(MAX(Table1[YEAR]);Table1[ACCUMULATED CASH FLOW] < 0)
VAR Numerator_ = CALCULATE(DISTINCT(Table1[ACCUMULATED CASH FLOW]);Table1[YEAR] = Year_) 
VAR YearNext_ = CALCULATE(MIN(Table1[YEAR]);Table1[YEAR] > Year_)
VAR Denominator_ = CALCULATE(DISTINCT(Table1[CASH FLOW]);Table1[YEAR] = YearNext_)
RETURN
Year_ + DIVIDE(Numerator_; Denominator_)

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Cheers  Datanaut

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.