Counting values in between two dates in Quicksight - pivot-table

I have a dataset in Quicksight that looks something like this;
I am trying to create a report of daily/weekly/monthly active users. For example, if the date/week/month is in the range of user's first_login & last_login, it should count that user. E.g. the report of Date: 15th March, should show all 3 users as per this dateset.
The report is in the form of Pivot table as below:
Currently, I am counting the distinct Client_ID for Last_login activity. But it keeps decreasing because the Dataset only saves/updates the latest last_login of the user.
Is there any way to modify the formula in a way to count users, who's first and last login fall within the date range?

Related

Google Datastudio: Categorize new and returning user id based on their first appearance date

I want to categorise users to the new and returning users based on their first appearance date in Data Studio, so if I select the date range of June 1, 2019, to June 30, 2019, every user with first appearance date is on that period is categorised as a new and every users before that period categorised as the returning users.
The data looks like this:
user_id
Firstcontact
9020784665
21/05/19
80302116604
21/05/19
34032004987
02/06/19
85963021828
03/06/19
42703694037
04/06/19
7985228940
05/06/19
39174203617
06/06/19
62014629759
06/06/19
71599733666
06/06/19
3617458365
06/06/19
I was considering to use the CASE function but nothing seemed to work.
I expect the output of new users based on selected date in Data Studio
This is something you'll need to create a segment for in Google Analytics to use in Data Studio

Google Data Studio date aggregation - average number of daily users over time

This should be simple so I think I am missing it. I have a simple line chart that shows Users per day over 28 days (X axis is date, Y axis is number of users). I am using hard-coded 28 days here just to get it to work.
I want to add a scorecard for average daily users over the 28 day time frame. I tried to use a calculated field AVG(Users) but this shows an error for re-aggregating an aggregated value. Then I tried Users/28, but the result oddly is the value of Users for today. The division seems to be completely ignored.
What is the best way to show average number of daily users over a time frame? Average daily users over 10 days, 20 day, etc.
Try to create a new metric that counts the dates eg
Count of Date = COUNT(Date) or
Count of Date = COUNT_DISTINCT(Date) in case you have duplicated dates
Then create another metric for average users
Users AVG = (Users / Count of Date)
The average depends on the timeframe you have selected. If you are selecting the last 28 days the average is for those 28 days (dates), if you filter 20 days the average is for those 20 days etc.
Hope that helps.
I have been able to do this in an extremely crude and ugly manner using Google Sheets as a means to do the calculation and serve as a data source for Data studio.
This may be useful for other people trying to do the same thing. This assumes you know how to work with GA data in Sheets and are starting with a Report Configuration. There must be a better way.
Example for Average Number of Daily Users over the last 7 days:
Edit the Report Configuration fields:
Report Name: create one report per day, in this case 7 reports. Name them (for example) Users-1 through Users-7. These are your Row 2 values. You'll have 7 columns, with the first report name in column B.
Start Date and End Date: use TODAY()-X where X is the number of days previous to define the start and end dates for each report. Each report will contain the user count for one day. Report Users-1 will use TODAY()-1 for start and end, etc.
Metrics: enter the metrics e.g. ga:users and ga:new users
Create the reports
Use 'Run reports' to have the result sheets created and populated.
Create a sheet for an interim data set you will use as the basis for the average calculation. The first column is date, the remaining columns are for the metrics, in this case Users and New Users.
Populate the interim data set with the dates and values. You will reference the Report Configuration to get the dates, and you will pull the metrics from each of the individual reports. At this stage you have a sheet with date in first columns and values in subsequent columns with a row for each day's values. Be sure to use a header.
Finally, create a sheet that averages the values in the interim data set. This sheet will have a column for each metric, with one value per column. The one value is calculated from the series in the interim data set, for example =AVG(interim_sheet_reference:range) or any other calculation you'd like to do.
At last, you can use Data Studio to connect to this data source and use the values. For counts of users such as this example, you would use Sum as the aggregation field type when you are creating the data source.
It's super ugly but it works.

How to create a dynamic - calculated - field in Salesforce?

Salesforce:
Every account has an agreement with my company. Once they have an agreement in place, they can start ordering products.
In the account record, I have a date field called "Agreement Approved On".
Ordered products are represented as "assets".
I want to create another field in the account record called "First Order Amount". This field should be populated dynamically, and should calculate the following:
Look for all of the account's assets created after the date field "Agreement Approved On".
Summarize the total of all assets ordered during the first order (within the same day).
Within the same day:
Let's assume the agreement was approved on January 1 2017. The
account started ordering on January 5 2017.
During January 5 2017, the account made 5 orders (8 different
assets), total is $1,000. This is the first order total - within the same
day.
After January 5 2017, the account made more orders, but they don't
count towards "first order amount".
So my question is - how do I create this "First Order Amount" field?
Thanks!
You need to setup a oncreate trigger on Asset taht will update the first order total amount field on Account.
In the trigger check whether now() > agreement approve date. If yes, check if there are any other assets with dateCreated < TODAY.
These two conditions will check whether there are any existing account assets and if the date is > agreement date. If there are existing assets, it means this is not the first order.
You can then get all asset amounts and add them and write the final amount to the account field.
See https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_triggers_context_variables.htm
for trigger syntax
and https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_dateformats.htm for date functions and literals.

Getting minimum values out of calculated table

I have:
a table with user names
a table indicating actions with columns for user name, action time, action name. Named events unique_events
I started collecting data on January. I want to have a column in my table of user names which indicates how long it has been since a user first used my application and the first of January.
So if a user first logged in in January, the value of the row with that user's name will be 0. If one logged in on March it will be 2.
I tried:
Column = DATEDIFF(01-01-2016, MIN(SELECTCOLUMNS(FILTER('events unique_events','events unique_events'[User Name] = Users[User Name]),"DatedTime", [DatedTime])),MONTH)
which returns an error saying the Min function needs a column reference.
I also tried the same with FirstDate instead of MIN which returned an error saying FirstDate can't be used with summarize functions.
Any other ideas on how to achieve this, or fix what I tried?
(for simplicity, I will call your table 'Events', and user login dates field 'User_Login_Date').
First, define your app start date as a measure:
App_Start_Date:= DATE(2016, 1, 1)
Then, define measure that finds min differences between Application Start Date and User Login dates:
User_Start_Diff=: MINX(Events, DATEDIFF([App_Start_Date], Events[User_Login_Date], Month))
Drop this measure into a pivot table against user names, and you should have your desired result.
How it works:
1) MINX goes record by record and calculates date differences for each customer login. It then finds minimum in the results;
2) When you drop the measure into a pivot table, it splits MINX results by customer, and recalculates min for each of them separately. You don't need to do the grouping.
Creation of [Start_Date] measure is not technically necessary but a matter of good style - don't hardcode values in your formulas, always create measures. You will thank yourself later when you need to make a change.

Group by array or shared value

My invoice report pull due dates depending on the selection of Payment Plan Code on UI (either semi, monthly, quarterly, annually, or even 18 installments.) It also accordingly pulls gross premium per due date. I need to pull this table per due date and the sum of the gross premium if they fall into one due date.
What I do is break and save the due dates into array. How can I group by them? Crystal doesn't seem to allow me to group by a shared value, or group by array.
You don't need array for this purpose.. using array complicates the report instead you can manipulate grouping like below:
Create a formula like below and use this formula to group.
if parameterselection = "monthly"
then Month(duedate)
else if parameterselection = "yearly"
then Year(duedate)
.
.
.
.
formula till end
Edit-------------------------------------------
In this case as per your comment you need to create one more group (Group2) with due date.
Now you have two groups group 1 is the one I wrote first and group2 using due date and this works

Resources