List Totals from a list

I’m trying with no luck to get a total from a list of data. using firebase as my rest api

Hi,
Have you try the formula SUM_BY_KEY () ?

https://docs.appgyver.com/docs/sum-by-key?highlight=sum

1 Like

We need more details on the list(s) schema so we can figure out the right formula.
Been on this task too since yesterday and depending on your list(s) structure, you may need MAP(), SELECT(), SELECT_BY_KEY(), or FLATTEN(), etc…

if you have an array, COUNT () might be what you need, but we can’t say for sure because we don’t know the schema of your data. Hello.



I am trying to get the total amount of “Total_Miles”.

I have tried all of those. I must be doing something wrong. The closest I got was the amount for the current record

1 Like

I’m no expert enough to analyze this screenshot properly, pls share the whole schema from data resource or the data variable.


Hopefully this is what you are looking for.

I am not familiar with that type of REST API schema.
I would do something like below so that:

  1. you MAP through all your documents and create a new list based on Total_Miles ;
  2. you FLATTEN the list of Total_Miles list so you turn this list of list into a single list ;
  3. you SUM BY KEY ‘Total_Miles’ criteria

SUM_BY_KEY(FLATTEN(MAP(data.onTheRevenue1, item.Total_Miles)), data.OnTheRevenue1.[something in between].Total_Miles
When you use MAP, you get access to new variables (like item.Total_Miles for example) for building your formula.
image

I tried to fix my schema like you suggested but the scheme stayed the same. The fields and integer value properties are still the same.

Ignore it and try the formula with the right variables bindings inside.

1 Like

SUM_BY_KEY(FLATTEN(MAP(data.onTheRevenue1, item.Total_Miles)), data.OnTheRevenue1.[something in between].Total_Miles

Like this???

No.
Start by typing MAP in the input field and confirm selection for MAP() then selected available variables on the left.

Not sure what variables to put in to the map. I’m sorry I’m new to this I’ve tried everything

I’m getting nowhere I have tried everything I can think of. I’m sure it has to be something simple. I’ve got everything else working I can enter information into the database and I can see the information from the database I just need to be able to get a total from all the entries in one field from the database.

Example:
Miles “12”
Miles “24”

Total miles “36” this is what I want to see

Sorry no fast internet until Friday morning
Try your formula without flatten?
Although I feel your available variables are not right. I’ve never seem variable looks. But I have not used REST for data yet.


Comes back with 0

Its shows all the entries but will not give me a total

Until I understand your schema it’s too difficult to help you out.
Show me the left menu when the cursor is on SUM BY KEY?