What's wrong with my Beast Mode Calculation?
When I tried to show the results from the queries below I get this error, "An issue has occurred during processing. We are unable to complete the request at this time"
AVG(sum(distinct`Users`)/ `Content ID`)
AVG(SUM(DISTINCT `Users`) over (order by `Content ID`))
I want the average of users over content id, but the results won't show.
Best Answer
-
... this is bad sql. while you can 'make it work'. it will be prone to invisible errors.
you can't SUM DISTINCT values. ... or at least... you shouldn't. you can COUNT(DISTINCT) values. I assume you're using sum(distinct) b/c you have multiple rows with the same value repeated. your hope is that if you sum(distinct) you'll remove duplicates. but if you have the same number of users for one content ID you'd get the 'wrong value'.
to get this to work, you MUST have content ID on an axis or in the order by clause. once you do that, you probably won't get the desired result b/c you'll have the sum( users) for each content id. which will be ONE VALUE. so when you then try to take the average of one value, you'll get the same number.
I go into it in depth here. https://www.youtube.com/watch?v=eifSYZIcPzg
but the two major action items are, restructure your data so you're not trying to do a sum(distinct) and 2 if you need to know the average across content_ID you may have to preaggregate your data before pulling it into analyzer.
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
Answers
-
... this is bad sql. while you can 'make it work'. it will be prone to invisible errors.
you can't SUM DISTINCT values. ... or at least... you shouldn't. you can COUNT(DISTINCT) values. I assume you're using sum(distinct) b/c you have multiple rows with the same value repeated. your hope is that if you sum(distinct) you'll remove duplicates. but if you have the same number of users for one content ID you'd get the 'wrong value'.
to get this to work, you MUST have content ID on an axis or in the order by clause. once you do that, you probably won't get the desired result b/c you'll have the sum( users) for each content id. which will be ONE VALUE. so when you then try to take the average of one value, you'll get the same number.
I go into it in depth here. https://www.youtube.com/watch?v=eifSYZIcPzg
but the two major action items are, restructure your data so you're not trying to do a sum(distinct) and 2 if you need to know the average across content_ID you may have to preaggregate your data before pulling it into analyzer.
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 -
Ahhhh I see. Thanks so much for your help, I really appreciate it!
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 738 Beast Mode
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 123 Manage
- 120 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive