Need to calculate daily/monthly ratio. How to combine two date ranges in one card?
Hi all,
I need to calculate a daily users / monthly users ratio, but I am stumped as to how to build the Beast Mode to indicate the following logic: "COUNT(DISTINCT `user id`) for every day and divide by COUNT(DISTINCT `user id`) for the whole month" This will be calculating this ratio over time.
I don't know if this can be built as a beast mode or if it shoud be done in the ETL, but mostly I am confused as to how to indicate both counts with different date ranges, one daily and one monthly in the same card.
Any help is much appreciated! Thanks.
Comments
-
Hello,
I think you can do it using a formula like this (for current month) :
COUNT(DISTINCT 'user_id')/COUNT(DISTINCT CASE WHEN YEAR(`your_date`) = YEAR(CURRENT_DATE()) AND MONTH(`your_date`) = MONTH(CURRENT_DATE()) THEN 'user_id')
Maybe there is a easier solution but I think it will do the job !
0 -
It also depends on how you want to present the informantion. If it was me I would do the following on Magic ETL:
Basically generate a table with the following fields (one row per date)
"Date", "Daily Distinct Users", "Monthly Distinc Users"
Create a beast mode as either Daily/Monthly (or AVG Daily/ AVG Monthly for Summary Numbers and so on)
You then use Date as your date grain, so you can trend it accross months, get averages and so on.
In more detail:
- Create a Month of Date column on the original table
- Create a Year of Date column on the original table
- Create a YearMonth column on the original table
- Group as Distinct Count on YearMonth
- Group as Distinct Count on Date and YearMonth
- Join the two new tables
- Select the columns you want to keep
0 -
Hi Rado98,
Thanks for the explanation, I am building DAU/MAU ratio and your post has been the most useful?
However, would you be so kind to explain in more details the processes required, in particular:
- How do I generate a table with "Date", "Daily Distinct Users", "Monthly Distinct Users"?
- I am using Date operation to extract Year of Date and Month of Date then I will use combine to get YearMonth Column, but I don't understand the next steps and how to join the two tables.
Thanks for your help.
G
0 -
Hi
As I recall:
Step 4.
Using the ETL Group function to generate the table.
Group by MonthYear and Count Distinct Users, call new column "distinct Monthly Users"
Step 5
Using the ETL Group function to generate the table.
Group by Date and MonthYear and Count Distinct Users, call new column "distinct Daily Users"
Join on MonthYear
0 -
Have a good think about what you want the data to mean and display.
I recommend that instead of JOINing the data as recommended by @rado98 that you UNION the two sets of data after adding a column Aggregation Level with constant values 'Daily' and 'Monthly'. This way you can avoid crazy math in your beast modes when you're calculating your ratio.
SUM( CASE WHEN AggLevel = 'daily' then CntDstnctMeasure END )/ SUM( CASE WHEN AggLevel = 'month' then CntDstnctMeasure END )
Have a think about how / if you want your report to respond to filters as you're defining your GROUP BY clause and aggregate function. Any columns that you eliminate means you can't use in filters.
I did a longer tutorial video that's lays out how I'd approach your problem while avoiding COUNT DISTINCT to give maximum functionality in dashboards. It might seem like a stretch for your use case but it'll work.
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 754 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive