I am trying to determine the total amount of messages sent from my G Suite account. I am streaming my logs to BigQuery.
Messages may appear in the logs multiple times so I can count the distinct message headers.
SELECT
count (DISTINCT message_info.rfc2822_message_id) as MessageIDCount
FROM `my data set`
This would count total inbound and outbound, so if I only want outbound I can add WHEN message_info.message_set.type = 8.
But the Sending Limits for gmail https://support.google.com/a/answer/2956491#sendinglimitsforrelay
The sending limits are not just total messages sent it counts based on the number of recipients.
I am interested in running a query that will provide total number of messages sent where if I sent an email to 2 people it would count as 2, If I sent to 10 it would count as 10, etc.
Essentially I want to determine how close I was to hitting sending limits for a given day.
Any Suggestions?
Below is for BigQuery Standard SQL
#standardSQL
SELECT
DATE(TIMESTAMP_MICROS(event_info.timestamp_usec)) day,
COUNT(address) AS total_recipients
FROM `project.dataset.gmail_log`,
UNNEST(message_info.destination) AS destination
WHERE EXISTS (SELECT 1 FROM UNNEST(message_info.message_set) WHERE type = 8)
GROUP BY day
it will return daily total number of recipients in below format
Row day total_recipients
1 2019-01-10 100
2 2019-01-11 100
3 2019-01-12 100
4 2019-01-13 100
5 2019-01-14 100
Related
For each "Job Number" group there are multiple "Quantity" records. I only require one "Quantity" record per "Job Number", so I have tried to achieve this by using an Average of the "Quantity". This works in isolation at Group Level, however I need to then show an average of "Quantity" at a higher group level
For example, Job Number 100000 has 4 records in the detail level with a Quantity of 5000 for each record, Job Number 100001 has 2 records in the detail level with a Quantity of 2000 for each record
Using the average function, the group level shows Job Number 100000 with one quantity record of 5000 and Job Number 100001 with one quantity record of 2000
At the higher group level, the average should be 3,500 (7,000 / 2) but it actually displays as 4,000 (24,000 / 6)
The formula should be a Sum of the Average Quantity / Distinct Count of Job Number
For the life of me I can't get this to work
Any help appreciated
Thank you
Create a Running Total and set the evaluate condition to 'On Change of Group':
Hi I have created a stream with has the following values from the topic,
"id VARCHAR, src_ip VARCHAR, message VARCHAR"
Now I need to see if failed_login repeates more than 3 times in given time then raise an alert. So I have created a table as below,
CREATE TABLE 231_console_failure AS \
SELECT src_ip, count(*) \
FROM console_failure \
WINDOW TUMBLING (SIZE 30 SECONDS) \
WHERE message = 'failed_login' \
GROUP BY src_ip \
HAVING count(*) > 3;
Now when I use my python script to consume from the topic as '231_console_failure' then I get a None continously when there is no match
And when there is a match i.e more that 3 in 30 sec then it gives that value. But say if there are 10 attempt in 30 sec then the consumer fetches 7 messages where each message differ with count from 4 to 10.
I know I can handle this in script by avoiding the None and take only higher count in given time. But is there any way to create a stream from the above table which will have only matched messages with groupby in KSQL?
This isn't currently possible in KSQL, but there is an enhancement request open if you want to upvote/track it: https://github.com/confluentinc/ksql/issues/1030
For now, per the same ticket, you can experiment with cache.max.bytes.buffering and commit.interval.ms to vary how often the aggregate is emmited.
I'm having some problems with grouping and running totals in crystal reports, I've found loads of info whilst googling but I'm looking a bit more info.
Currently I have 3 tables, jobs, times and costs, I have a running total to calculate the value of the time.hours and another for the costs.amount.
The issue I'm having is that the costs are being multiplied by the amount of time.hours records that exist.
so if a job has 3 time.hours records and there is only one record of costs.amount that
cost is being multiplied by that about of records
So what i end up with is this
Job Hours Costs
123 5 0
123 4 100
123 3 0
=========================
12 100
which is exactly right, now if i add another running total without resetting then my total ends up as
========================
12 300
I think this is happening because of the way i have them grouped but im not sure how to make them group to only job.ID
This was solved using ( ) to break the formula down
({timesheet.Time_Date} <={?timDateUJC} and {jobsheet1.Job_JobCompleted} = 0)
or
({materialcost.Inv_Date} <= {?supDateUJC} and {jobsheet1.Job_JobCompleted} = 0)
I am trying to get a count of records for a the Charge Group; however it is counting my suppressed data as well. I understand that suppressed data is only hidden and doesn't effect any calculation, but how can I adjust my formula so it doesn't take the suppressed data.
I attempted to do a running total field however I receive an error
A running total cannot refer to a print time formula Details: #Customer Drop Max Amount
Within the report there are multiple Trailer Charge Groups that are basically shippers and their destinations are marked as Drop Customers
I only want one record for two Drop Customers to be computed, so whenever another trailer falls into the record for Drop Customer I have to change the count field to show that their should only be one.
The formula field I am doing that for is Charge group count
IF {#TRAILER CHARGE GROUP} = 'INTCNEWNC' THEN Count ({TRAILER_CUSTOMER_ZONE.TRAILER_ID} , {#TRAILER CHARGE GROUP}) - 6
ELSE IF {#TRAILER CHARGE GROUP} <> 'INTCNEWNC' THEN Count ({TRAILER_CUSTOMER_ZONE.TRAILER_ID}, {#TRAILER CHARGE GROUP} )
I am using Crystal Reports XI on a DB2 server.
Thanks in advance!
edit: INTCNEWNC is the charge group, whereas ASHLADVNC and MARSBIVA are the drop customers. You can clearly see the individual counts for Drop customers are fine but the count for charge groups is where I am struggling.
1) Create running total fields for both the specific drop customer and charge group.
2) A formula field stating
IF CHARGEGROUP = 'MY CHARGE GROUP' then (rt.charge group) - (rt.drop customer 1) - (rt.drop customer 2) + 2 else count(trailer)
I have a listing of clients grouped by zip code. i have only an interest in the total number of clients in each zip code grouping. I am trying to limit my report to a certain number of groups determined by the user entering a percent as a parameter. For example this is the list of zip code information
zip code c 50 clients 50% of total clients
zip code d 25 clients 25% of total clients
zip code e 10 clients 10% of total clients
zip code a 10 clients 20% of total clients
zip code b 5 clients 5% of total clients
(They have been sorted in order descending order)
Print the report listing the top 80% of total clients.
I have tried using the percentofdistinctcount summary field but I can't get the program to add the values together to meet but not exceed the percentage given as the parameter, 80% in this case. If I try to enter Sum(percentofdistinctcount(fieldname)) I get an error telling me the field can't be summarized.
thanks
To the extent you understand the problem use below solution.
You are using a parameter for the percentage and at the same time you are showing data with that input of the paramter.
In this case you need to calculate percentage for all zipcodes in the report and then conditinally supress as per the user input.
Example:
if percent value<80
then false
else true
After the supress apply your summation contion on the displayed results.
If this doesn't help you I apologize