Good afternoon everyone,
could someone help me get a specific value of firebase for sum because i am having difficulties. I’ve tried a few things but to no avail.
I would like to get all the fields named “consumption” and make the sum
{
“55AMJ05081990CAA|2” : {
“13h17m2” : {
“consumo” : 80,
“vendor” : “Joelton”
},
“13h17m30” : {
“consumo” : 25,
“vendor” : “Maria”
}
},
“55CPC08101987MAA|2” : {
“13h16m42” : {
“consumo” : 503,
“vendor” : “Joelton”
},
“13h17m17” : {
“consumo” : 30,
“vendor” : “Maria”
}
}
}
1 Like
What have you tried? Can you share a screenshot of your blocks? There might be a simple correction that can be made.
1 Like
Sorry, I removed the blocks.
I had tried to treat the list with objects but to no avail.
So I just managed to get this far and get to this list. But what I really need is to add what’s on the list.
Follow where I left off.
1 Like
First to notice is Firebase already provides you with the green value as an object. You should access the properties of the object instead of converting it to JSON. So first thing to do is to remove generate JSON from object
.
Next, you can use get object properties of
with the app variable vListaFireDB as the input to the list viewer Lasta_Finalizer which will give you a list of timestamps you have in your database.
This is just for you to see that it is working. What you should do is use it in a loop to go through each timestamp and get the property consomo
and add it to a running sum or any kind of variable. This way you get the total of each QR code.
1 Like
@ccosta
I used the JSON text you provided and made this block to get the sum. I used a label to provide the QR code and therefore my code is this
It brings the following results
Hope you’ll find it helpful.
2 Likes