Creating percentages from responses

I've also noticed that this function gives a percentage out of 100 per message...
Is there a way of collecting up multiple messages and outputting results as an overall percentage?

Yes, you can send them individually out of separate outputs on the function node. If you look at the docs for writing functions it tells you how to do that.

I don't know what you mean by that. I think I have previously asked that you give and example showing what you want to see so that we can understand the maths you want to do.
However first make sure that you understand how the function that you have works. Then you should be able to make an attempt at changing the maths to make it do what you want.

Great, thanks!

Sorry, I mean that about 50 people will each be able to select one of the four options so I’d like to be able to accumulate all of their responses and create overall percentages.

Does that make sense?

As I keep saying provide a concrete example with numbers and show what you want out of it. Words are easily misunderstood, an example with numbers should be clear.

Hi Colin.

So the project consists of three or four voting questions.
These are generated from an off-the-shelf event app..

Each question has 4 answers to choose from.
Around 50 clients can each vote once on each question via the app.

Every time someone votes a message gets sent through via an Ably real-time feed.
These messages come through as the message format at the top of this thread.

I need to collect up all of the individual votes for A, B, C or D and output a percentage for the overall result.

Below are the results that the app itself generates.
Unfortunately, I don't have access to these results and have to regenerate them from the individual messages.
Vote_1

Does that make more sense?

Many thanks
Patrick

In that situation I would start by writing the results to a database when they come in, then you can analyse the data as and when required.

Thanks Colin.
Do you know of any tutorials for creating databases and analysing data in them?

Sqlite is probably the easiest to start playing with so you could search for sqlite tutorial. Once you understand how the database works then look at how to use it in node-red. There are sqlite nodes available.

Hi.

I don't like just butting in but I am wanting to help if I can.

Graphicsop....

A function node can have multiple outputs.
When you are editing the code, below that window is a small selector which has the number of outputs. Default 1.

You can increase that to...... Well, more than enough for your needs.

Reading what you are doing, may I suggest a different method?

When the button is pressed, the message is created. Looking at your first post, you have two fields: poll and person.

When the message is sent put a split node in and split on the msg.poll field.
if (msg.poll == 31754) output 1
if (msg.poll == 31755) output 2
if (msg.poll == 31756) output 3
(you get it)

Then you can send those off to parts of the code to process them as required.

Though I am not 100% sure what you want to do, that may help you.