I am trying to find a way to modify the following PQL code to change the KPI by the selection of the specific time frame.
KPI("days_considered_for_inv_lt")
*
MOVING_MAX(
PU_SUM(
DOMAIN_TABLE(ROUND_MONTH("o_custom_StockHistoryStorageLocation"."CurrentPeriod")),
FILTER_TO_NULL(COALESCE(
CURRENCY_CONVERT(
"o_custom_StockHistoryStorageLocation"."BaseTotalValuatedStockQuantity"
*
BIND(
"o_custom_MaterialMasterStorage",
PU_LAST("o_celonis_MaterialMasterPlant",
"o_celonis_StockHistory"."UnitPrice"))
,FROM(
BIND(
"o_custom_MaterialMasterStorage",
PU_LAST("o_celonis_MaterialMasterPlant",
"o_celonis_StockHistory"."BaseCurrency")))
-- ,FROM("o_celonis_MaterialMasterPlant"."BaseCurrency")
,TO('EUR')
,PU_MAX(CONSTANT(), "o_celonis_StockHistory"."CurrentPeriod")
,"o_celonis_CurrencyConversion"
,'EURX'
,"o_custom_MaterialMasterStorage"."CLIENT"
)
, 0.0
))),0,0)
/
MOVING_SUM(
PU_SUM(
DOMAIN_TABLE(ROUND_MONTH(
"o_custom_StockHistoryStorageLocation"."CurrentPeriod"))
,FILTER_TO_NULL(COALESCE(
CURRENCY_CONVERT(
(COALESCE(
QUANTITY_CONVERT (
"o_custom_StockHistoryStorageLocation"."ConsumptionQuantity"
,FROM (BIND("o_custom_MaterialMasterStorage", PU_LAST("o_celonis_MaterialMasterPlant","o_celonis_StockHistory"."QuantityUnit")))
, TO ("o_celonis_Material"."StockKeepingUnit")
, "o_celonis_Material"."Number"
, "o_celonis_QuantityConversion"
)
,"o_custom_StockHistoryStorageLocation"."ConsumptionQuantity"
)
* BIND("o_custom_MaterialMasterStorage", PU_LAST("o_celonis_MaterialMasterPlant","o_celonis_StockHistory"."UnitPrice")))
,FROM (BIND("o_custom_MaterialMasterStorage", PU_LAST("o_celonis_MaterialMasterPlant","o_celonis_StockHistory"."BaseCurrency")))
/* -- ,FROM("o_celonis_StockHistory"."BaseCurrency") */
,TO('EUR')
,"o_custom_StockHistoryStorageLocation"."CurrentPeriod"
,"o_celonis_CurrencyConversion"
,'EURX'
,"o_custom_MaterialMasterStorage"."CLIENT"
)
, 0.0
))
)
,1,12)