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
- 1.9K Product Ideas
- 1.9K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 307 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3K Transform
- 112 SQL DataFlows
- 649 Datasets
- 2.2K Magic ETL
- 4K Visualize
- 2.5K Charting
- 790 Beast Mode
- 78 App Studio
- 43 Variables
- 746 Automate
- 187 Apps
- 475 APIs & Domo Developer
- 68 Workflows
- 16 DomoAI
- 40 Predict
- 17 Jupyter Workspaces
- 23 R & Python Tiles
- 406 Distribute
- 117 Domo Everywhere
- 279 Scheduled Reports
- 10 Software Integrations
- 139 Manage
- 136 Governance & Security
- 8 Domo Community Gallery
- 47 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 113 Community Announcements
- 4.8K Archive