Hola Equipo Appsheet
Estoy realizando una aplicación para una granja de gallinas ponedoras, debo ingresar los huevos recogidos cada día, pero necesito sumar los huevos recogidos cada semana y ese dato agregarlo a otra tabla, como podría hacer este calculo, Gracias

Welcome to the community !

If this is about displaying aggregation, you may want to add a virtual column “Week”
with expression:
`ISOWEEKNUM([yourDate])`
Then, use a table view to display information with the Group_by option, pick “weekNumber”, and calculation option : “Sum :: Week”

For reference:

Here is an example of what it looks like:
with COUNT:

with SUM:

3 Likes

Thank You @Aurelien
I understand but what i want to do is create the accumulated of the eggs colected
Then

Day. Egss colected. Accumulated
Mon. 200. 200
Tus. 200. 400
Wed. 150. 550
Thu. 200. 750
Fri. 200. 950
Sat. 150. 1100
Sun. 200. 1300

So, when Day = Sunday , insert [Accumulated] in “another table”
"
“Another Table”

Week. Week’s Egss. … … …Other information
Any Number. 1300

And when starts the Next week [Accumulated] should be begins with the number of [Eggs colected] from Monday
Example

Day. Eggs colected. Accumulated
Mon. 250. 250
Tus. 300. 550

OK.
I’m not sure to understand properly: you don’t care about which week it is, just weekday ?

If so, you may want to create a table with just the weekday, and set a relation between that table and the one you have at the moment.

My suggestion:

1. table “EggCollection” (the one you have at the moment), with columns:
==> key: type Text, initial value expression `UNIQUEID()`
==> timeStamp: type DateTime, initial value expression `NOW()`
==> quantity: type Number

2. Slice “eggCollectionFromThisWeek”, that will have the last week’s rows only
==> source table EggCollection
==> row filter condition : `[TimeStamp]>NOW()-7`

3. Table “Week”, with columns:
==> keys: 1, 2 ,3, 4, 5 ,6, 7
==> Values: “sunday”, “monday”, “tuesday”, etc

4. Back on table “EggCollection”, add a virtual column :

• “weekday”, expression: WEEKDAY([TimeStamp]), Type Ref, Source table: Week
1. Back on Table “Week”, add virtual* columns:
• SumEggsCollected”, expression : `SUM([Related eggCollectionFromThisWeek][Quantity])`
• AccumulatedEggsCollected”, expression:
``````SUM(
SELECT(eggCollectionFromThisWeek[SumEggsCollected],
[WeekDay]<=[_THISROW].[WeekDay]
)
)
``````

• I didn’t try this, this is a suggestion
• this should work, with limitation: `WEEKDAY()` expression takes Sunday as day 1. You mway want to use `SWITCH()` expression as an alternative in order to take monday as day 1.

Note2:
Example for the alternative WEEKDAY() expression:

``````SWITCH(WEEKDAY([TimeStamp]),
1,7,
2,1,
3,2,
4,3
5,4
6,5,
6
)
``````

For reference:

3 Likes

@Aurelien ok, thanks so much, I Will try It… I want to learn what you know, what do i need to study, where can i learn all of these expressions that You wrote here…

Regards from Colombia .

1 Like
3 Likes

Thank You @Steve

2 Likes