How to form aggregate-of-aggregate values that can be filtered by card date ranges?
I am trying to create a table in Visualizer that displays how many customers have made at least 1, 2, etc. purchases as below. The original dataset is raw transaction data, and I've tried creating columns that display the "total # of purchases" by the customer for each transaction (aka each row in the data).
This does work, but the problem is this "total # of purchases" column becomes inaccurate when the user changes the date range of the card (i.e. someone that made 1 transaction in July and 3 in August will have a "total # of purchases" correctly displayed as 4, but if the date range is narrowed to just August the value should change to 3). As user changes to the card date range cannot affect ETL/Viewer date ranges, this approach does not work.
As Visualizer's Beast Mode does not accept aggregates of aggregates, I'm having a hard time implementing the columns there. Can anyone suggest any approaches I can take in Visualizer?
Answers
-
I have a meeting to get to in a couple minutes. So this is going to be a bit rushed. Hopefully this helps…
Creating a sample set:Customer Name
Purchase Date
Transaction Amount
John Doe
2024-07-01
50.00
Jane Smith
2024-07-02
75.00
John Doe
2024-08-01
30.00
Jane Smith
2024-08-03
40.00
John Doe
2024-09-01
100.00
Mike Johnson
2024-08-01
20.00
John Doe
2024-09-15
25.00
Mike Johnson
2024-09-15
60.00
Jane Smith
2024-09-20
35.00
Mike Johnson
2024-09-21
15.00
Sarah Lee
2024-09-01
100.00
distinct:
COUNT(DISTINCT `Customer Name`)
grouping:
CASE
WHEN COUNT(`Purchase Date`) OVER (PARTITION BY `Customer Name`) >= 10 THEN '10+ transactions'
WHEN COUNT(`Purchase Date`) OVER (PARTITION BY `Customer Name`) = 9 THEN '9 transactions'
WHEN COUNT(`Purchase Date`) OVER (PARTITION BY `Customer Name`) = 8 THEN '8 transactions'
WHEN COUNT(`Purchase Date`) OVER (PARTITION BY `Customer Name`) = 7 THEN '7 transactions'
WHEN COUNT(`Purchase Date`) OVER (PARTITION BY `Customer Name`) = 6 THEN '6 transactions'
WHEN COUNT(`Purchase Date`) OVER (PARTITION BY `Customer Name`) = 5 THEN '5 transactions'
WHEN COUNT(`Purchase Date`) OVER (PARTITION BY `Customer Name`) = 4 THEN '4 transactions'
WHEN COUNT(`Purchase Date`) OVER (PARTITION BY `Customer Name`) = 3 THEN '3 transactions'
WHEN COUNT(`Purchase Date`) OVER (PARTITION BY `Customer Name`) = 2 THEN '2 transactions'
ELSE '1 transaction'
ENDtest:
COUNT(`Purchase Date`) OVER (PARTITION BY `Customer Name`)
** Was this post helpful? Click Agree or Like below. **
** Did this solve your problem? Accept it as a solution! **0 -
Though not exactly it, thanks for responding! I was looking for something closer to the table below, where the rows in the table are based on how many customers made at least 1, 2, 3, etc. transactions.
The problem I'm now having is that each row should also be including the counts of the rows above (as a customer can't make 3 transactions without making 2 and 1 first). Is there any way to make a Visualizer table's rows not mutually exclusive?
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
- 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