Is it possible to calculate 6 months of data for a metric?
I am trying to collect Customer data Month over Month data for a metric that uses data from the past 6 months.
For example -
January 2022 would include customer data from July 2021 to January 2022
February 2022 would include customer data from August 2021 to February 2022
and so on..
Any help is appreciated!
Thanks!
Vik
Comments
-
This is the sql query if that helps
Select count(distinct Customer) from CustomerData where InvoiceDate between '2021-07-01' and '2022-01-31'
0 -
You can do this in Magic ETL pretty easily with a formula tile, group by tile and a rank and window tile.
In the formula tile, use the LAST_DAY() function to normalize the dates in each month to the same day, like this: LAST_DAY(datefield)
In the group by tile, group by your last day field and do a distinct count of customer. This will give you a total for each month.
In the rank & window tile, give your field a name like 6-month total choose sum and choose your customer count field that you created in the group by tile. Enter 5 for preceding and 0 for following.
This will give you a 6 month total for each month, assuming you aren't missing any months.
Hope this helps.
**Check out my Domo Tips & Tricks Videos
**Make sure to any users posts that helped you.
**Please mark as accepted the ones who solved your issue.1 -
Thanks Mark. This was very helpful.
1 -
@MarkSnodgrass i think this is logically flawed.
if you calculate the number of distinct customers in a month, you cannot add each month's number for a year.
i.e. 50 in jan, 35 in feb = 85 distinct customers.
you would be assuming that you had no repeat customers...
if your data is measured per month and you want a rolling 6 months, what you would could do is create a rolling window for each month that represents the appropriate set of dates.
i.e on Jan 21 i need a window spanning Jan 20 to Jan 21 (so use a formula tile to calculate last_day() for Jan 21 and then last_day for the month one year ago (date_diff).
now we need an aggregate table representing one row per month (table_a). so just GROUP BY date and MIN(date_lastYear).
then JOIN table_a onto the full activity table, table_b. Ideally you'd want to JOIN on table_b.date between table_a.date_lastYear and table_a.date.
but since Domo doesn't support JOIN on a BETWEEN clause you can do a cross apply. add a column to the tables _join_col = 1. then JOIN table_a to table_b on _join_col. then filter table_b.date between table table_a ...
Now you can calculate COUNT DISTINCT for table_b.customer_id.
You can now take this and join it back to your original activity table.
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"1
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
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 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