# Nan data without raw value

**URL:** https://discourse.nodered.org/t/nan-data-without-raw-value/79872
**Category:** Dashboard
**Tags:** node-red-dashboard, database, function-node
**Created:** [17 July 2023 09:38 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872 "2023-07-17T09:38:02Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![GAOJY11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaojy11/32/80980_2.png) [@GAOJY11](https://discourse.nodered.org/u/GAOJY11)
#### Post date: [17 July 2023 09:38 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/1 "2023-07-17T09:38:02Z")

</div>

```auto
[
    {
        "id": "87549861f4edea54",
        "type": "function",
        "z": "18dcf239.c8ae63",
        "name": "function 11",
        "func": "var previousCount = flow.get('previousCount') || 0;\nvar currentCount = msg.payload;\nvar latestCount = currentCount - previousCount;\n\n// Update previousCount for the next calculation\nflow.set('previousCount', currentCount);\n\n// Calculate the total count from the flow context\nvar totalCount = flow.get('totalCount') || 0;\ntotalCount += latestCount;\nflow.set('totalCount', totalCount);\n\n// Prepare the output message with the calculated values\nmsg.payload = {\n currentCount: currentCount,\n previousCount: previousCount,\n latestCount: latestCount,\n totalCount: totalCount\n};\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 690,
        "y": 960,
        "wires": [
            [
                "3d3e1af6daef9124"
            ]
        ]
    },
    {
        "id": "94720f8732b47ffc",
        "type": "inject",
        "z": "18dcf239.c8ae63",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "30",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "6",
        "payloadType": "num",
        "x": 490,
        "y": 960,
        "wires": [
            [
                "87549861f4edea54"
            ]
        ]
    },
    {
        "id": "7079b441c0109457",
        "type": "inject",
        "z": "18dcf239.c8ae63",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 490,
        "y": 1040,
        "wires": [
            [
                "87549861f4edea54"
            ]
        ]
    },
    {
        "id": "baefe0a43b083fa3",
        "type": "ui_text",
        "z": "18dcf239.c8ae63",
        "group": "5f07e40cf7e1cba4",
        "order": 3,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "OEE",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "style": false,
        "font": "",
        "fontSize": 16,
        "color": "#000000",
        "x": 1030,
        "y": 960,
        "wires": []
    },
    {
        "id": "3d3e1af6daef9124",
        "type": "function",
        "z": "18dcf239.c8ae63",
        "name": "function 12",
        "func": "// Get the latestCount from the flow context\nvar latestCount = flow.get('latestCount');\n\n// Calculate OEE\nvar oee = (latestCount * 17 / 300).toFixed(2);\n\n// Prepare the output message with the calculated OEE value\nmsg.payload = oee;\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 870,
        "y": 960,
        "wires": [
            [
                "baefe0a43b083fa3"
            ]
        ]
    },
    {
        "id": "1b3e8b3e4862222c",
        "type": "inject",
        "z": "18dcf239.c8ae63",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "30",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "9",
        "payloadType": "num",
        "x": 490,
        "y": 900,
        "wires": [
            [
                "87549861f4edea54"
            ]
        ]
    },
    {
        "id": "5f07e40cf7e1cba4",
        "type": "ui_group",
        "name": "Conveyor",
        "tab": "656075cf63d99d76",
        "order": 2,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "656075cf63d99d76",
        "type": "ui_tab",
        "name": "Output",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]
why the above node are showing a Nan value.[
    {
        "id": "87549861f4edea54",
        "type": "function",
        "z": "18dcf239.c8ae63",
        "name": "function 11",
        "func": "var previousCount = flow.get('previousCount') || 0;\nvar currentCount = msg.payload;\nvar latestCount = currentCount - previousCount;\n\n// Update previousCount for the next calculation\nflow.set('previousCount', currentCount);\n\n// Calculate the total count from the flow context\nvar totalCount = flow.get('totalCount') || 0;\ntotalCount += latestCount;\nflow.set('totalCount', totalCount);\n\n// Prepare the output message with the calculated values\nmsg.payload = {\n currentCount: currentCount,\n previousCount: previousCount,\n latestCount: latestCount,\n totalCount: totalCount\n};\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 690,
        "y": 960,
        "wires": [
            [
                "3d3e1af6daef9124"
            ]
        ]
    },
    {
        "id": "94720f8732b47ffc",
        "type": "inject",
        "z": "18dcf239.c8ae63",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "30",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "6",
        "payloadType": "num",
        "x": 490,
        "y": 960,
        "wires": [
            [
                "87549861f4edea54"
            ]
        ]
    },
    {
        "id": "7079b441c0109457",
        "type": "inject",
        "z": "18dcf239.c8ae63",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 490,
        "y": 1040,
        "wires": [
            [
                "87549861f4edea54"
            ]
        ]
    },
    {
        "id": "baefe0a43b083fa3",
        "type": "ui_text",
        "z": "18dcf239.c8ae63",
        "group": "5f07e40cf7e1cba4",
        "order": 3,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "OEE",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "style": false,
        "font": "",
        "fontSize": 16,
        "color": "#000000",
        "x": 1030,
        "y": 960,
        "wires": []
    },
    {
        "id": "3d3e1af6daef9124",
        "type": "function",
        "z": "18dcf239.c8ae63",
        "name": "function 12",
        "func": "// Get the latestCount from the flow context\nvar latestCount = flow.get('latestCount');\n\n// Calculate OEE\nvar oee = (latestCount * 17 / 300).toFixed(2);\n\n// Prepare the output message with the calculated OEE value\nmsg.payload = oee;\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 870,
        "y": 960,
        "wires": [
            [
                "baefe0a43b083fa3"
            ]
        ]
    },
    {
        "id": "1b3e8b3e4862222c",
        "type": "inject",
        "z": "18dcf239.c8ae63",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "30",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "9",
        "payloadType": "num",
        "x": 490,
        "y": 900,
        "wires": [
            [
                "87549861f4edea54"
            ]
        ]
    },
    {
        "id": "5f07e40cf7e1cba4",
        "type": "ui_group",
        "name": "Conveyor",
        "tab": "656075cf63d99d76",
        "order": 2,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "656075cf63d99d76",
        "type": "ui_tab",
        "name": "Output",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

```

---

<div class="post-metadata">

### Author: ![GAOJY11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaojy11/32/80980_2.png) [@GAOJY11](https://discourse.nodered.org/u/GAOJY11)
#### Post date: [17 July 2023 09:53 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/2 "2023-07-17T09:53:37Z")

</div>

How to exact one value for next calculation

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [17 July 2023 10:03 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/3 "2023-07-17T10:03:31Z")

</div>

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

### Author: ![GAOJY11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaojy11/32/80980_2.png) [@GAOJY11](https://discourse.nodered.org/u/GAOJY11)
#### Post date: [17 July 2023 10:19 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/4 "2023-07-17T10:19:25Z")

</div>

var previousCount = flow.get('previousCount') || 0;  
var currentCount = msg.payload;  
var latestCount = currentCount - previousCount;

// Update previousCount for the next calculation  
flow.set('previousCount', currentCount);

// Calculate the total count from the flow context  
var totalCount = flow.get('totalCount') || 0;  
totalCount += latestCount;  
flow.set('totalCount', totalCount);

// Prepare the output message with the calculated values  
msg.payload = {  
currentCount: currentCount,  
previousCount: previousCount,  
latestCount: latestCount,  
totalCount: totalCount  
};

return msg;

May i know how to extract the latestCount value for next calculation

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [17 July 2023 12:21 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/5 "2023-07-17T12:21:11Z")

</div>

Please see my previous post.

> [@GAOJY11](#):
>
> May i know how to extract the latestCount value for next calculation

And explain what you mean by that.

Perhaps this will be helpful:

There’s a great page in the docs ([Working with messages : Node-RED](https://nodered.org/docs/user-guide/messages)) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

![BX00Cy7yHi](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/d/bd1f333a9e043b061b39917c328b0094d3e52d30.gif)

---

<div class="post-metadata">

### Author: ![GAOJY11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaojy11/32/80980_2.png) [@GAOJY11](https://discourse.nodered.org/u/GAOJY11)
#### Post date: [18 July 2023 02:24 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/6 "2023-07-18T02:24:06Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/f/7f217b4fd49276887d653f8773d436d257c556c8.png)  
It only displays the text, I want it to be displayed as an individual item in the dashboard.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [18 July 2023 12:50 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/7 "2023-07-18T12:50:38Z")

</div>

You have still not edited your original post in order to allow us to import your flow in order to see what you are doing.

---

<div class="post-metadata">

### Author: ![GAOJY11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaojy11/32/80980_2.png) [@GAOJY11](https://discourse.nodered.org/u/GAOJY11)
#### Post date: [18 July 2023 13:10 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/8 "2023-07-18T13:10:21Z")

</div>

```auto
[
    {
        "id": "87549861f4edea54",
        "type": "function",
        "z": "18dcf239.c8ae63",
        "name": "function 11",
        "func": "var previousCount = flow.get('previousCount') || 0;\nvar currentCount = msg.payload;\nvar latestCount = currentCount - previousCount;\n\n// Update previousCount for the next calculation\nflow.set('previousCount', currentCount);\n\n// Calculate the total count from the flow context\nvar totalCount = flow.get('totalCount') || 0;\ntotalCount += latestCount;\nflow.set('totalCount', totalCount);\n\n// Prepare the output message with the calculated values\nmsg.payload = {\n currentCount: currentCount,\n previousCount: previousCount,\n latestCount: latestCount,\n totalCount: totalCount\n};\n\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 810,
        "y": 1020,
        "wires": [
            [
                "3a2aa592376cda0d",
                "2f16174714bec8fa",
                "3ae2f0efb3ec7142",
                "ec64378aae3e679f",
                "f4b9779e9dcb395a"
            ]
        ]
    },
    {
        "id": "94720f8732b47ffc",
        "type": "inject",
        "z": "18dcf239.c8ae63",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "30",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "6",
        "payloadType": "num",
        "x": 570,
        "y": 1040,
        "wires": [
            [
                "87549861f4edea54"
            ]
        ]
    },
    {
        "id": "7079b441c0109457",
        "type": "inject",
        "z": "18dcf239.c8ae63",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0",
        "payloadType": "num",
        "x": 590,
        "y": 1120,
        "wires": [
            [
                "87549861f4edea54"
            ]
        ]
    },
    {
        "id": "1b3e8b3e4862222c",
        "type": "inject",
        "z": "18dcf239.c8ae63",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "30",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "9",
        "payloadType": "num",
        "x": 570,
        "y": 980,
        "wires": [
            [
                "87549861f4edea54"
            ]
        ]
    },
    {
        "id": "3a2aa592376cda0d",
        "type": "debug",
        "z": "18dcf239.c8ae63",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1010,
        "y": 980,
        "wires": []
    },
    {
        "id": "2f16174714bec8fa",
        "type": "ui_text",
        "z": "18dcf239.c8ae63",
        "group": "5f07e40cf7e1cba4",
        "order": 2,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "text",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "style": false,
        "font": "",
        "fontSize": 16,
        "color": "#000000",
        "x": 1010,
        "y": 1060,
        "wires": []
    },
    {
        "id": "3ae2f0efb3ec7142",
        "type": "ui_gauge",
        "z": "18dcf239.c8ae63",
        "name": "",
        "group": "de8c1377fba8b816",
        "order": 4,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "Latest",
        "label": "units",
        "format": "{{currentCount}}",
        "min": 0,
        "max": "10",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "diff": false,
        "className": "",
        "x": 1010,
        "y": 1120,
        "wires": []
    },
    {
        "id": "ec64378aae3e679f",
        "type": "ui_gauge",
        "z": "18dcf239.c8ae63",
        "name": "",
        "group": "de8c1377fba8b816",
        "order": 4,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "Previous count",
        "label": "units",
        "format": "{{value}}",
        "min": 0,
        "max": "1",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "diff": false,
        "className": "",
        "x": 1040,
        "y": 1180,
        "wires": []
    },
    {
        "id": "f4b9779e9dcb395a",
        "type": "ui_gauge",
        "z": "18dcf239.c8ae63",
        "name": "",
        "group": "de8c1377fba8b816",
        "order": 4,
        "width": 0,
        "height": 0,
        "gtype": "gage",
        "title": "Total Count",
        "label": "units",
        "format": "{{value}}",
        "min": 0,
        "max": "1",
        "colors": [
            "#00b500",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "",
        "seg2": "",
        "diff": false,
        "className": "",
        "x": 1030,
        "y": 1240,
        "wires": []
    },
    {
        "id": "5f07e40cf7e1cba4",
        "type": "ui_group",
        "name": "Counter",
        "tab": "656075cf63d99d76",
        "order": 3,
        "disp": true,
        "width": "15",
        "collapse": true,
        "className": ""
    },
    {
        "id": "de8c1377fba8b816",
        "type": "ui_group",
        "name": "OEE",
        "tab": "656075cf63d99d76",
        "order": 5,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "656075cf63d99d76",
        "type": "ui_tab",
        "name": "Output",
        "icon": "dashboard",
        "order": 8,
        "disabled": false,
        "hidden": false
    }
]

```

---

<div class="post-metadata">

### Author: ![GAOJY11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaojy11/32/80980_2.png) [@GAOJY11](https://discourse.nodered.org/u/GAOJY11)
#### Post date: [18 July 2023 13:10 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/9 "2023-07-18T13:10:59Z")

</div>

I want to display the individual values in the node-red gauge

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [18 July 2023 13:14 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/10 "2023-07-18T13:14:56Z")

</div>

Did you read my original post? It explained how you have to add three backtick characters on lines before and after the flow or code. I will edit your posts for you.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [18 July 2023 13:20 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/11 "2023-07-18T13:20:10Z")

</div>

Use this format in the dashboard nodes

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/d/4db70dec47a58ee57577e215d7760ecf46312539.png)

---

<div class="post-metadata">

### Author: ![GAOJY11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaojy11/32/80980_2.png) [@GAOJY11](https://discourse.nodered.org/u/GAOJY11)
#### Post date: [18 July 2023 13:50 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/12 "2023-07-18T13:50:18Z")

</div>

I did read the original post, but I am still very confused. Thank you for your quick update and comments, the question has been resolved, thank you so much.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [18 July 2023 14:02 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/13 "2023-07-18T14:02:54Z")

</div>

If you do not understand a post you should ask for clarification, not just ignore it.

---

<div class="post-metadata">

### Author: ![GAOJY11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaojy11/32/80980_2.png) [@GAOJY11](https://discourse.nodered.org/u/GAOJY11)
#### Post date: [18 July 2023 14:06 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/14 "2023-07-18T14:06:29Z")

</div>

Sorry regarding that. My apologies.

---

<div class="post-metadata">

### Author: ![GAOJY11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/gaojy11/32/80980_2.png) [@GAOJY11](https://discourse.nodered.org/u/GAOJY11)
#### Post date: [18 July 2023 14:07 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/15 "2023-07-18T14:07:52Z")

</div>

Just to clarify, if I want to add a time picker to extract the data from a specific timeframe, how should I construct it

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [1 August 2023 14:08 UTC](https://discourse.nodered.org/t/nan-data-without-raw-value/79872/16 "2023-08-01T14:08:30Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
