Skip to content

Example using javascript in KPIs

An example to calculate the speed of the CNC milling machine using json script.


To calculate the speed of the CNC milling machine, follow these steps:

  1. Click “Add a KPI”.
    Add a KPI
  2. Name: Speed-KPI
  3. Description: Speed of the spindle
  4. Calculation cycle: 10 minutes
  5. Inputs: in1 = T_L_A_Equipping / Machine_KPIs / Quality
  6. Inputs: in2 = T_L_A_Equipping / Machine_KPIs / Quality
  7. Outputs: out = T_L_A_Milling_CNC / KPI_Quality / Quality
  8. Formula: const last = flow.get('lastSpeed'); if (last !== null && last !== undefined) { out = in1 - last; } if (in1 !== null && in1 !== undefined) { flow.set('lastSpeed', in1); }
  9. Click Save.


The output will be displayed in KPIs page. You can create dashboard to display the KPIs in the dashboard page by using the available widgets. For more information on adding KPIs to the dashboard, see Dashboards Actions.


Any questions left?

Ask the community

Except where otherwise noted, content on this site is licensed under the MindSphere Development License Agreement.

Last update: April 21, 2022