Flexible SUM Aggregates With Duplicate Values in Dataset
Hello everyone.
I have a data set that looks like this:
This data set shows product purchases at the customer level. Thus, product IDs are duplicated in the data set.
Here's the challenge.
I want to show the total value of products, counting each product value only once in a SUM. I've added a Product Rank column as a helper, so that the SUM formula can look like this:
SUM(CASE WHEN Product Rank = 1 then Price END)
The issue is when I add a filter to the dashboard for Customer Type (say, for "In Store"), then that SUM formula will not capture the total value because Product Rank = 2.
It seems what I'd need to do is run my rank and window on the fly based on the filters that are selected. Essentially, the issue is needing a way to de-duplicate the values that contribute towards the SUM calculation.
Best Answer
-
@jmmc you can do this with SUM(DISTINCT ())
SUM(DISTINCT Price) FIXED (BY Product ID)
Yields the following results. You can see that the column fixed1 only includes the total once per id.
David Cunningham
** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
** Did this solve your problem? Accept it as a solution! ✔️**2
Answers
-
@jmmc you can do this with SUM(DISTINCT ())
SUM(DISTINCT Price) FIXED (BY Product ID)
Yields the following results. You can see that the column fixed1 only includes the total once per id.
David Cunningham
** Was this post helpful? Click Agree 😀, Like 👍️, or Awesome ❤️ below **
** Did this solve your problem? Accept it as a solution! ✔️**2 -
I am confused on how these are duplicates. Are they not separate transactions? For example, one online and one in store in the sample data above? If you want to see total value, why would you want to exclude customers?
If I solved your problem, please select "yes" above
0 -
@david_cunningham this is excatly what I was looking for, this is a very powerful feature. Thank you!
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