Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
tauceef
Partner - Contributor III
Partner - Contributor III

Calculating values in script inside loop

Hello Everyone,

We are trying to calculate values of certain KPIs at script side and storing those values into Qvd but we are facing challenge in that, need help on that.

Below is the script which we have written and with that we are not getting appropriate output:

LET rowText = NoOfRows('Threshold');

for i=1 to $(rowText) // loop through every row

let vMETRICID = Peek('METRICID',$(i),'Threshold'); 
Let vDOMAINID = Peek('DOMAINID',$(i),'Threshold');

Let vBrkFixReslDen='Count({<DOMAINID={''$(vDOMAINID)''},ExcludeFromSLAFlag={0},SLA_ResolutionTargetBreachFlag={0,1},isInternal={1},ToolType={1}>}Task)';
Let vBrkFixReslNum='Count({<DOMAINID={''$(vDOMAINID)''},ExcludeFromSLAFlag={0},SLA_ResolutionTargetBreachFlag={0},isInternal={1},ToolType={1}>}Task)';


Set vBrkFixRespDen='Count({<DOMAINID={''$(vDOMAINID)''},ExcludeFromSLAFlag={0},SLA_ResponseTargetBreachFlag={0,1},ToolType={1}>}IncidentID)';
Set vBrkFixRespNum='Count({<DOMAINID={''$(vDOMAINID)''},ExcludeFromSLAFlag={0},SLA_ResponseTargetBreachFlag={0},ToolType={1}>}IncidentID)';

 

Let SLA_M1 = '=Pick(match($(vMETRICID),51,61),
Num($(vBrkFixReslNum)/$(vBrkFixReslDen),''##0.00%''),
Num($(vBrkFixRespNum)/$(vBrkFixRespDen),''######.0'')

)';

SLAValues:
Load '$(vMETRICID)' as Metid, '$(vDOMAINID)' as Domid, '$(SLA_M1)' as SLAMI,
'$(vMETRICID)'&'|'&'$(vDOMAINID)' AS SLAID
AutoGenerate 1;

LET vQVDexists = if(FileSize('lib://QVD_DATA/SLAValues.qvd') > 0, 1, 0);


IF vQVDexists = 0 THEN
Store SLAValues into [lib://QVD_DATA/SLAValues.qvd](qvd);
Else
Concatenate(SLAValues)
Load * FROM [lib://QVD_DATA/SLAValues.qvd]
(qvd) where Not Exists(SLAID);

Store SLAValues into [lib://QVD_DATA/SLAValues.qvd](qvd);
End if;
Drop table SLAValues;
Next

 

in the SLAMI column of SLAValues table instead of getting the result value we are getting a string with formula in it like:

"=Pick(match(51,51,61),
Num(Count({<DOMAINID={'1'},ExcludeFromSLAFlag={0},SLA_ResolutionTargetBreachFlag={0},isInternal={1},ToolType={1}>}Task) / Count({<DOMAINID={'1'},ExcludeFromSLAFlag={0},SLA_ResolutionTargetBreachFlag={0,1},isInternal={1},ToolType={1}>}Task),'##0.00%'),


Num(Count({<DOMAINID={'1'},ExcludeFromSLAFlag={0},SLA_ResponseTargetBreachFlag={0},ToolType={1}>}IncidentID) / Count({<DOMAINID={'1'},ExcludeFromSLAFlag={0},SLA_ResponseTargetBreachFlag={0,1},ToolType={1}>}IncidentID),'######.0')

)"

but instead of formula we want to get the calculated value in this column or else if we can get the value in the chart/table when we select this column that should also work.

Looking forward for help.

Regards, Tauceef

Labels (1)
1 Reply
tauceef
Partner - Contributor III
Partner - Contributor III
Author

Hello Everyone,

Any help would be great, please suggest if I am missing something in the above code.

Regards, Tauceef