I would like to find an average value for the daily production count by summing up values in the bar chart, How can I find it? I tried running avg, avgover and unfortunately, I get errors, any help would be greatly appreciated.

I tried the same formula but I got this error "1
sumOver({Daily_Production},[{TMST}],PRE_AGG)/distinctCountOver({Daily_Production},[{TMST}],PRE_AGG)
Execution order mismatch: PRE_FILTER calculations canât have PRE_Agg operands.
I tried some other solutions posted in the community as well, but maybe I am missing something.

These are my calculations to find the average value but it gives inaccurate because of the missed first daily production record.

Maybe there is some other best way to find the average of the daily production, but when I tried with level aware calculations I always got errors, that is why I tried this way.

Any help would be greatly appreciated. Thanks in advance

Can you show a few rows of your raw data, including your GCNT field so that I can understand the granularity of the data? What does each row of your dataset represent?

Hi @David_Wong, Actually my device is an IoT-enabled embedded device, from my device every 3 minutes or based on events data is stored in DB, and GCNT is my global counter value and it will increase with respect to the time. This is my main field to calculate the print count, production rate, etc.

A distinct count of GCNT will not give the actual production rates.

No, the Daily_Production doesnât represent the number of rows in my data. It is a calculated field to find the daily production rate. My embedded device is a printer and it continuously prints 24 hours a day. So I need to find out the production rate of each day, for that I have one unique field is GCNT,
it will increase with respect to the TMST.

For example,
if GCNT for 17-09-23 = 2000
GCNT for 16-09-23 = 1500
GCNT for 15-09-23 = 900
so production for 17 is 2000 - 1500 = 500
production for 16 is 1500 - 900 = 600

Are the values of GCNT sequential or are there duplicates values for GCNT? Iâm trying to understand why there are only 222 unique values of GCNT on Sep 18 when the difference in MaxGCNT on Sep 17 and Sep 18 is that big.

I donât think thereâs a way to nest periodOverPeriodDifference with avg or avgOver, so Iâm trying to see if thereâs a different way you can calculate Daily_Production. Is there any way you can calculate Daily_Production in your dataset using SQL?

Yes, GCNT values are usually sequential, and in most cases, they do not have duplicate values. However, there are instances when multiple events occur simultaneously within seconds, and in such cases, GCNT values can be duplicated. For example, if a device reboot, print activation, and cartridge change all happen simultaneously, it will generate these events with the same GCNT value. Once printing begins, the GCNT value will sequentially increase.

I am not sure about calculating the Daily_Production in my dataset using SQL.

Can you verify that the total production is correct?
maxOver(GCNT, , PRE_AGG) - minOver(GCNT, , PRE_AGG)

If you take the max GCNT in the dataset and subtract the min GCNT, that should give you the total production, right?

If the total production is correct but the average is not what you expect, then thereâs an issue with the denominator (number of days). Does the dataset contain days with no data? If there are days with no data, when calculating the average, do you want to divide by all days or only by the days with data?

You can try sumOver({Daily_Production}, [], PRE_AGG) by itself and youâll see that it doesnât work. QuickSight doesnât allow periodOverPeriodDifference inside the sumOver.