cancel
Showing results for 
Search instead for 
Did you mean: 

Mutiplication SAP SAC Data Action

nasser_itani
Participant
0 Kudos
162

Hello Experts,

I am trying to do a multiplication inside SAC advanced formulas, I know that multiplication in advanced formula works somehow different then addition and subtraction. Below is my code and I am trying to figure out what I am doing wrong basically.

 

CONFIG.HIERARCHY = [d/DIM_COSTCENTER].[h/H1]
MEMBERSET [d/DIM_BUDGETYEAR] = "2025"
MEMBERSET [d/DIM_AUDIT] = "INPUT_HR"
MEMBERSET [d/Measures] = "Amount"
MEMBERSET [d/DIM_BUSINESSLINE] = "GEN"
MEMBERSET [d/DIM_DETAILITEM] = "#"
MEMBERSET [d/DIM_PHASE] = "#"
MEMBERSET [d/DIM_SCENARIO] = "#"
MEMBERSET [d/DIM_ACCOUNT] = BASEMEMBER([d/DIM_ACCOUNT], "51100000")
MEMBERSET [d/DIM_COSTCENTER] !="#"
// Define variables
VARIABLEMEMBER #x OF [d/Measures]
VARIABLEMEMBER #y OF [d/Measures]

// Store actuals for 2025 in #x
DATA([d/Measures] = #x) =
RESULTLOOKUP([d/DIM_AUDIT] = "LOAD_ACTUALS", [d/DIM_BUDGETYEAR] = "2025", [d/Version] = "public.Actual", [d/DIM_SCENARIO] = "G_RO")

// Store input HR values in #y for unassigned cost center
DATA([d/Measures] = #y, [d/DIM_COSTCENTER] = "#") =
RESULTLOOKUP([d/DIM_COSTCENTER] = "#", [d/DIM_BUDGETYEAR] = "#", [d/DIM_SCENARIO] = "#", [d/DIM_AUDIT] = "INPUT_HR", [d/Version] = "public.Plan")

// Loop through cost centers (excluding unassigned)
FOREACH [d/DIM_COSTCENTER]

// Ensure values exist before multiplying
IF RESULTLOOKUP([d/Measures] = #x, [d/DIM_COSTCENTER] = [d/DIM_COSTCENTER]) != NULL AND
RESULTLOOKUP([d/Measures] = #y, [d/DIM_COSTCENTER] = "#") != NULL THEN

DATA([d/Measures] = "Amount", [d/DIM_COSTCENTER] = [d/DIM_COSTCENTER], [d/Date] = "202512") =
RESULTLOOKUP([d/Measures] = #x, [d/DIM_COSTCENTER] = [d/DIM_COSTCENTER]) *
RESULTLOOKUP([d/Measures] = #y, [d/DIM_COSTCENTER] = "#")

ENDIF

ENDFOR

Accepted Solutions (0)

Answers (2)

Answers (2)

N1kh1l
Active Contributor

@nasser_itani 

Easiest Way to solve multiplication issue is as below.

  • You do not need to check if value exists using IF. If there is no value multiplication will anyway not generate any data. I am not sure why would you even need the FOREACH.
  • Multiplication works like a join condition on all dimension/measure of the model in 2 result lookups. So easiest way is take the sample records of the 2 result lookup in excel and then ensure you specify all non common dimensions between 2 result lookups. Non common dimensions are those whose values are different in 2 lookups. As you are storing the 2 initial results in # variable a simple debug of those 2 Data statements will give you the record sample generated.

Nikhil

William_Yu
Product and Topic Expert
Product and Topic Expert
0 Kudos
I assume you only need one single line something similar to this: DATA( [d/Date] = "202512") = RESULTLOOKUP([d/DIM_AUDIT] = "LOAD_ACTUALS", [d/DIM_BUDGETYEAR] = "2025", [d/Version] = "public.Actual", [d/DIM_SCENARIO] = "G_RO") * RESULTLOOKUP([d/DIM_COSTCENTER] = "#", [d/DIM_BUDGETYEAR] = "#", [d/DIM_SCENARIO] = "#", [d/DIM_AUDIT] = "INPUT_HR", [d/Version] = "public.Plan")