the table name is "kharjaT", the fields are : "kharjaDate", "kharjaUnite", "kharjaTa3yine", "kharjaPrice",
How to sum all "kharjaUnite" of the same "kharjaTa3yine" for a every month and show the total in the last day of the month (like I made in the second table) in access ?
| kharjaDate | kharjaUnite | kharjaTa3yine | kharjaPrice |
|---|---|---|---|
| 20/01/2024 | 5 | tomato | 50 |
| 25/01/2024 | 6 | tomato | 60 |
| 15/02/2024 | 4 | tomato | 40 |
| 25/02/2024 | 3 | tomato | 30 |
| kharjaDate | kharjaUnite | kharjaTa3yine | kharjaPrice |
|---|---|---|---|
| 30/01/2024 | 11 | tomato | 55 |
| 29/02/2024 | 7 | tomato | 35 |
Use report Sorting & Grouping with aggregate calcs in textboxes. Set groups on kharjaTa3yine field and on a calculation of kharjaDate to return a value that can be used to group by month. Decide which should be primary and secondary group and put aggregate calcs in the second group footer.
Need year and month parts for date period group.
To extract year and month as a single value:
Year(kharjaDate) & Format(kharjaDate, "00")To calculate last day of month:
DateAdd("d", -1, DateSerial(Year(DateAdd("m", 1, kharjaDate)), Month(DateAdd("m", 1, kharjaDate)), 1))Use either for grouping and for display on report. Calculation can be in query used for report RecordSource. Then report references those fields.
The output you show is total for kharjaUnite and average for kharjaPrice. Aggregate expressions in textboxes:
=Avg(kharjaPrice)=Sum(kharjaUnite)This is fairly basic report design in Access.