4 tables - procedure
IDs, Status, Period, Consumption tables
Status table related to IDs. Status of each IDs for date (3 columns IDs, Status, Date)
Example:
A1, 145, 1.1.2021
A1 167, 1.2.2021
Period table (3 columns PeriodName, StartDate, EndDate)
Example:
January 21, 1.1.2021, 1.2.2021
Consumption table related to IDs (3 columns, IDs, Consumption, PeriodName)
Need a procedure for button on Period table to calculate that ...
9 replies
-
For selected Period of course
-
Just to verify there is a reference field, called PeriodName, in Consumption to Period. Or is PeriodName a dynamic choice field that pulls data from the Period table and displays the PeriodName.
If PeriodName is a reference field in Consumption, then you should see a View element in Period table showing all related Consumption records.
I'm guessing you want the field Consumption to be calculated, but I'm not sure how you want the field calculated (sum, counted, avgeraged).
-
Yes, you're right, PeriodName is related to Consumption. Calculation is simple. I need to calculate consumption of each IDs, which is defference of statuses between StartDate and EndDate ...
-
You said PeriodName is related but you didn't claify how (through a reference field or dynamic choice). We'll go with reference for now.
If you select a record in your Period table do you see a View element that shows all related records from the Consumption table? You can then do simple calculations on the column you need.
I'm not sure what you want the button to do? You don't need a button to run calculations unless you want to put the results into a static field. Is that what you want to do?
If you want a running total then you only need to create a formula field with:
sum(Consumption.Consumption) <--you can put avg at the beginning as well
Or just modify the View element that I mentioned previously.
-
I understand but it is not so easy for me.
PeriodTbl and ConsumptionTbl are related by PeriodName, but consumption is calculated as difference between 2 rows in Status table.
Like ...
ID = A1
PeriodTbl
January 21
StatusTbl rows
A1, 1.1.2021, 65 kWh
A1, 1.2.2021, 86 kWh
then i need in ConsumptionTbl
A1, January 21, 21 kWh
-
You show that the Status table stores kWh data but you don't give us the name of the field.
How are records in Status related to Period? You show a field called Date in Status, but there are two date fields in Period.
-
STATUS tbl has 3 fields - pic. There is no relation PERIOD to STATUS, only PERIOD to CONSUMPTION.
-
Meter status is registered to STATUS tbl with date. Then i need to calculate consumption to CONSUMPTION tbl for PERIOD form PERIOD tbl.
-
I'm confused. You posted this:
StatusTbl rows
A1, 1.1.2021, 65 kWh
A1, 1.2.2021, 86 kWh
Which made me think Status held kWh data.
Anyways, so let me see if I understand what you want.
You have records in Consumption and they all have a PeriodName associated with each record. You want to find all Consumption records with matching PeriodNames. Then you want to subtract the data from the Consumption field in record 1 from record 2.
Question 1: will there always ONLY be two records in Consumption related to a PeriodName? If not then that complicates things.
Question 2: will the larger consumption data always be the 2nd record found, if naturally sorted by record Id?
Content aside
- 3 yrs agoLast active
- 9Replies
- 358Views