Using Partition by with Count

Hi,
I have this beastmode that is taking the % of people over $1000 in revenue and dividing it by the total # of people. It behaves correctly when I have only one terminal selected, however it shoots up to 350% when no terminal is selected. What is causing this? I tried removing the Partition by in the count distinct but then I receive .02%. The formula below gives me accurate numbers when only one terminal is selected.
I tried to switch the second Partition by clause to driverID and that was incorrect as well.
Any advice would be helpful!
(SUM(CASE WHEN AVG(Revenue
) >= 1000 THEN 1 ELSE 0 END) OVER (PARTITION BY DriverID
))
/
COUNT(DISTINCT DriverID
) OVER (PARTITION BY MPP_TERMINAL_NAME
)
Answers
-
Have you tried using FIXED (BY MPP_TERMINAL_NAME) ?
0 -
Craig_Lynch
I am getting this error which is weird because this formula
COUNT(DISTINCT
DriverID
) fixed (BYMPP_TERMINAL_NAME
)works on its own but when I put it into this formula I get this error.
(SUM(CASE WHEN AVG(
Revenue
) >= 1000 THEN 1 ELSE 0 END) OVER (PARTITION BYDriverID
))
/
COUNT(DISTINCTDriverID
) Fixed (BYMPP_TERMINAL_NAME
)An issue has occurred during processing. We are unable to complete the request at this time - 'undefined'
0 -
Hello @ColinHaze,
Handle cases where the denominator may be zero by using the NULLIF() function.
If you found this post helpful, please use π‘/π/π/π below! If it solved your problem, don't forget to accept the answer.
0 -
Still getting the undefined error?
0 -
Hello @ColinHaze,
As a reference, I'm sending the info regarding FIXED function:
You can see from the link that FIXED function requires double parentheses. Could you please also try this:
SUM(COUNT(DISTINCTΒ
DriverID
) Fixed (BYMPP_TERMINAL_NAME
))If you found this post helpful, please use π‘/π/π/π below! If it solved your problem, don't forget to accept the answer.
0
Categories
- All Categories
- Product Ideas
- 2.1K Ideas Exchange
- Connect
- 1.3K Connectors
- 309 Workbench
- 7 Cloud Amplifier
- 10 Federated
- Transform
- 664 Datasets
- 120 SQL DataFlows
- 2.3K Magic ETL
- 823 Beast Mode
- Visualize
- 2.6K Charting
- 86 App Studio
- 46 Variables
- Automate
- 194 Apps
- 484 APIs & Domo Developer
- 90 Workflows
- 24 Code Engine
- AI and Machine Learning
- 23 AI Chat
- 4 AI Projects and Models
- 18 Jupyter Workspaces
- Distribute
- 119 Domo Everywhere
- 283 Scheduled Reports
- 11 Software Integrations
- Manage
- 143 Governance & Security
- 11 Domo Community Gallery
- 49 Product Releases
- 13 Domo University
- Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 116 Community Announcements
- 5K Archive