Output wrong topic name

There is 4 input and output the min value and name of sensor.
As in pic min is 1, but sensor name is "sensor4", but it should be "sensor4".
cant figure how to fix


flows (9).json (5.2 KB)

The join node will output the last topic it receives, you would need to store the topic in the message, and alter it after the join.
e.g

[{"id":"10dc67b7f1544cfd","type":"inject","z":"4c74a996ec0dcce6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"0.1","topic":"sensor1","payload":"1","payloadType":"num","x":170,"y":80,"wires":[["b7ed48e0.8ad26"]]},{"id":"b7ed48e0.8ad26","type":"change","z":"4c74a996ec0dcce6","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.value","tot":"msg"},{"t":"set","p":"payload.sensor","pt":"msg","to":"topic","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":480,"y":60,"wires":[["9b80fac1.4d62e8"]]},{"id":"09f774e5a20bce7e","type":"inject","z":"4c74a996ec0dcce6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"0.1","topic":"sensor2","payload":"2.1","payloadType":"num","x":170,"y":120,"wires":[["b7ed48e0.8ad26"]]},{"id":"a3b77181baac77bf","type":"inject","z":"4c74a996ec0dcce6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"0.1","topic":"sensor3","payload":"5.7","payloadType":"num","x":170,"y":160,"wires":[["b7ed48e0.8ad26"]]},{"id":"40641e8232f9c750","type":"inject","z":"4c74a996ec0dcce6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":"0.1","topic":"sensor4","payload":"7.2","payloadType":"num","x":170,"y":200,"wires":[["b7ed48e0.8ad26"]]},{"id":"9b80fac1.4d62e8","type":"join","z":"4c74a996ec0dcce6","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":490,"y":120,"wires":[["9d32943.7172068"]]},{"id":"9d32943.7172068","type":"change","z":"4c74a996ec0dcce6","name":"change","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload.*^(value)[0]","tot":"jsonata"},{"t":"move","p":"payload.sensor","pt":"msg","to":"topic","tot":"msg"},{"t":"move","p":"payload.value","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":180,"wires":[["7a83392268023e11"]]},{"id":"7a83392268023e11","type":"switch","z":"4c74a996ec0dcce6","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"sensor1","vt":"str"},{"t":"eq","v":"sensor2","vt":"str"},{"t":"eq","v":"sensor3","vt":"str"},{"t":"eq","v":"sensor4","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":430,"y":240,"wires":[["c2d9cbe7.35c678"],["c2d9cbe7.35c678"],["c2d9cbe7.35c678"],["c2d9cbe7.35c678"]]},{"id":"c2d9cbe7.35c678","type":"debug","z":"4c74a996ec0dcce6","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":670,"y":160,"wires":[]}]

Thank you very much