cancel
Showing results for 
Search instead for 
Did you mean: 

Data Action with conditional IF not funtion

S0020706010
Explorer
0 Kudos

Hello SAP Community,

I am creating a data action that has the following logic where I am calculating fields based on various conditions,

Everything works fine until I get to the PurchasesProduction calculation.

which has the following formula

DATA([d/CONCEPTO_INV] = "ComprasProduccion") = RESULTLOOKUP([d/CONCEPTO_INV] = "StockSeguridad", [d/Version] = %OriVersion%, [d/Date] = "202205") + RESULTLOOKUP([d/CONCEPTO_INV] = "PptoVentas") - RESULTLOOKUP([d/CONCEPTO_INV] = "StockInicial")

When I execute the data action in the history it shows me the result well

Formula.

ComprasProduccion = StockSeguridad = 200 + PptoVentas = 165 - StockInicial 415 = -50

Now I must add a logic to tell it that everything that is less than < 0 then 0 if not PurchasesProduction and for this add the following condition in the data action:

IF RESULTLOOKUP([d/CONCEPTO_INV] = "ComprasProduccion")<0 THEN

DATA([d/CONCEPTO_INV] = "ComprasProduccion")=0

ELSE DATA([d/CONCEPTO_INV] = "ComprasProduccion")=RESULTLOOKUP([d/CONCEPTO_INV] = "ComprasProduccion")

ENDIF

But the final result when executing the data action is a different result than expected:

As shown, it shows 165 when according to the conditional it should show 0 since -50 is less than 0.

Can someone tell me the procedure that I must correct to correct and that it works correctly?

William_Yu
Product and Topic Expert
Product and Topic Expert
0 Kudos

Is the data line on the lowest grranularity(leave nodes) of all dimensions in your model? Or it's an aggregated value on some dimension?

Please always verify your logic on the lowest granularity.

Accepted Solutions (0)

Answers (1)

Answers (1)

S0020706010
Explorer
0 Kudos

Hi William.

This is the data action code:

The dimensions model is:

Is this correct or would you include some dimension?