Function node to filter 2 values out

Hi to all,
How can I filter out 2 quality check (qc) values in my payload? Can I use a function node?


Many thanks for help

Yes you will be able to do it in a function node, add a debug node and show us an example of the message that contains them if you need more advice

or maybe a change node set to delete them ?

15.7.2019, 14:12:44.075node: 1ebcf650.656f2a1522a388105841f081acef04a2782eb8/Extruder/T_Zone_2_IST_Temperatur,T_Zone_2_SOLL_Temperatur: msg: array[2000]

[ object, object, object, object, object, object, object, object, object, object … ]

So you are sending an array with thousands objects.
How wide is your screen? Can you actually visualise all this data?

Where are you getting this data from?
Is it a database?
Are you building it in your flow? It might be better to not add it in the first place rather than try to filter it out.
However if you do want help to filter it out, seeing what one of this objects contain is important.

Thats what I tried

Thats how the payload looks like!




delete: msg.payload.T_Zone_2_IST_Temperatur_qc

No change!

It is still their

What is the output of msg.payload. (debug node screenshot) - i suspect an array.

That would work if you only had one object, but you have 2000 in an array. Which is why if this is coming from a database, it might be more efficient to fix what puts in there in the first place.

Completely agree with this -- somewhere there is probably a SQL select statement that is returning everything, instead of just those fields that you want to display. Narrowing down your query, and grouping the 1000's of data points into chunks of time, will greatly improve the performance of the UI chart.

But, for future reference, I would use a JSONata expression to remove those properties from your raw data (assuming you cannot change the raw data that is returned). Here is one way to use a change node to remove those *_qc properties from the entire array of objects:

Here are a couple expressions I can think of to return just the fields you need:

  1. "sift" each object, keeping only properties that do not end with _qc
payload.$sift(function($val,$key) {
  1. modify each object in-place, deleting any properties that end with _qc
payload ~> | $ | {}, $keys($)~>$filter(/.*_qc/) |
  1. build a new array of objects, using only selected properties from each object
    "T_Zone_2_SOLL_Temperatur": T_Zone_2_SOLL_Temperatur,
    "T_Zone_2_IST_Temperatur": T_Zone_2_IST_Temperatur,
    "_time": _time

I found a solution see below
Solution is a function block

Many thanks to everybody for help and input

So you only delete the first [0] element ?

You are right. It was only deleting Array index 0
But now it is working

Thanks bakman2

The solution from @shrickus is more elegant but more advanced.
Actually I didn't even know you could do delete msg...