cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

cumulative delta calculation using data actions in SAC

guvvala_sairam
Explorer
0 Kudos
186

We have a requirement to calculate the cumulative delta across the planning horizon(example from Jan 2025 to Dec 2026) ,we have 3 specific measures namely

1. IR_Shift ,2.CP_Rates ,3. Refreshed_rates

Ir_shift is the data action calculated measure where as cp_rates and refreshed_rates are input measure.

For the initial month of the planning horizon IR Shift is the difference of refreshed rates and cp rates(ir shift =refreshed - cp) progressively for  the  next month should be refreshed and cp difference minus previous month  ir shift and for the 3rd month should be refreshed and cp difference minus  sum of previous  2 month  ir shift.

In the below table we have values from Jan to Dec and the formulas will be

for 1st month ir_shift=refrehsed-cp  (1000-50)

for 2nd month ir =(2000-100)-950

similarly for 12th month ir = (refreshed - cp) - sum( all the 11 months ir_shift)

MeasuresJANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC
IR_Shift950950102086010801110940105099010201020800
CP_Rates5010080220140309040503010210
Refreshed_Rates100020003000400050006000700080009000100001100012000

 

seeking Help for the data action script

 

Accepted Solutions (1)

Accepted Solutions (1)

William_Yu
Product and Topic Expert
Product and Topic Expert

I would imagine similar code like this(I haven't tested it at all): 

MEMBERSET [d/Date] = BASEMEMBER([d/Date], "[2025]")
MEMBERSET [d/Measures] = "IR_Shift"

VARIABLEMEMBER #YTD_SHIFT OF [d/Measures]

FOREACH [d/Date] ASC
  DATA() = RESULTLOOKUP([d/Measures] = "Refreshed_rates") - RESULTLOOKUP([d/Measures] = "CP_Rates")
         - RESULTLOOKUP([d/Measures] = #YTD_SHIFT, PREVIOUS(1, "MONTH", [d/Date]))
  DATA([d/Measures] = #YTD_SHIFT) = RESULTLOOKUP() + RESULTLOOKUP([d/Measures] = #YTD_SHIFT, PREVIOUS(1, "MONTH", [d/Date])
ENDFOR

Answers (1)

Answers (1)

MoonJun
Product and Topic Expert
Product and Topic Expert

Hi @guvvala_sairam 

Please refer to another resolution of the Advanced formulas script.  

MEMBERSET [d/Date] = BASEMEMBER([d/Date], "[2025]")

VARIABLEMEMBER #Delta_CP_Rates OF [d/Measures]
VARIABLEMEMBER #Delta_Refreshed_Rates OF [d/Measures]

DATA([d/Measures] = #Delta_CP_Rates)
= RESULTLOOKUP([d/Measures] = "CP_Rates")
- RESULTLOOKUP([d/Measures] = "CP_Rates", [d/Date] = PREVIOUS(1))
DATA([d/Measures] = #Delta_Refreshed_Rates)
= RESULTLOOKUP([d/Measures] = "Refreshed_Rates")
- RESULTLOOKUP([d/Measures] = "Refreshed_Rates", [d/Date] = PREVIOUS(1))

DATA([d/Measures] = "IR_Shift")
= RESULTLOOKUP([d/Measures] = #Delta_Refreshed_Rates)
- RESULTLOOKUP([d/Measures] = #Delta_CP_Rates)

Regards,

Moonjun