cancel
Showing results for 
Search instead for 
Did you mean: 

SAC Foreach restricted by time

Deb_D
Participant
0 Kudos
613

Hello, 

In my CAPEX project I have a parameter for the project life expected - for example 6 years that are inserted today.
On the other hand, I have the first year of investment set as "1" in the relevant year
I want to create a foreach calculation on a "Discount (life) Years" for further calculations
and my question is how to create the scope of 2024 to 2024+6 on my data action using the above inserted assumptions?

thanks
PS print screens 

 

Deb_D_0-1723122951900.png

Deb_D_1-1723123082084.png

Deb_D_2-1723123316707.png

 

Thank you 

Deb

 

N1kh1l
Active Contributor
0 Kudos

So you mean Discount Life Years for project = Year of First Investment (2024) + Useful life (6) so 2024 to 2029

MoonJun
Product and Topic Expert
Product and Topic Expert

Hi @Deb_D

I have another script to get your expected result. The main logic is the same as the previous script. 

The code is below

MEMBERSET [d/Date] = "2024" TO "2033"
MEMBERSET [d/Measures] = "Value"
MEMBERSET [d/Investments_Developments] = ("JM_EU", "JM_HQ")

INTEGER @First_Year
INTEGER @Project_Life

FOREACH [d/Investments_Developments]
	@Project_Life = RESULTLOOKUP([d/Account] = "Project_Life_in_Years")
	
	IF RESULTLOOKUP([d/Account] = "First_Investment_Year") = 1 THEN
		@First_Year = YEAR([d/Date])
	ENDIF

	IF YEAR([d/Date]) >= @First_Year THEN
		IF @Project_Life > (YEAR([d/Date]) - @First_Year) THEN
			DATA([d/Account] = "Discount_Life_Years") = YEAR([d/Date]) - @First_Year + 1
		ENDIF
	ENDIF
ENDFOR

Result of the script

AF_Script.png

 

 

 

 

 

 

 

I hope this helps you.

Moonjun

View Entire Topic
thomas_beck
Advisor
Advisor

Hi @Deb_D ,

You can also check the example on equipment depreciation using Advanced Formulas from the SAC Help: https://help.sap.com/docs/SAP_ANALYTICS_CLOUD/00f68c2e08b941f081002fd3691d86a7/e88b9a87633c4e19a0dbd...

It does use some parameters so can be easily adapted.

 

Regards,

Thomas

Deb_D
Participant
0 Kudos
@thomas_beck Thank you