Dividing in SQL
I currently have this code: categorizing some leads.
Select
`Year-Month`
,`Lead Source`
,`Product Line`
,`Product Models`
,`Country`
,`Early Stage No Movement`
,`Stage 0 to Early`
,`Early to Lost`
,`Early to Won`
,`Early to Late`
,`Late to Lost`
,`Late to Won`
,Sum(`Early to Lost`+`Early to Won`+`Early to Late`) AS 'Total Low to High'
,SUM(`Early Stage No Movement`+`Stage 0 to Early`+`Early to Lost`+`Early to Won`+`Early to Late`+`Late to Lost`+`Late to Won`) AS 'Total'
FROM `aggregation_categorization`
GROUP BY
`Year-Month`
,`Lead Source`
,`Product Line`
,`Product Models`
,Country
This runs fine, the next thing I am trying to do is add in the %.
SELECT *
,`Total Low to High`/`Total` AS '% Of Low to High'
FROM `formulas`
This works fine as well, but when I place it in a sumo table aggregating it does work. Any suggestions would be awesome.
Thank you.
Best Answer
-
Given the math you've put on the screen, there is no reason to run this ETL as a SQL transform. Just keep your data unaggregated.
Be careful with
Sum(`Early to Lost`+`Early to Won`+`Early to Late`) AS 'Total Low to High'
for any row, if any column contains the value null, the entire result will be null. this is the appropriate adjustment.
Sum(ifnull(`Early to Lost`,0) +ifnull(`Early to Won`,0)+ifnull(`Early to Late`,0) ) AS 'Total Low to High'
to do the division you're describing, just calculate the ratio in a beast mode (you may have to build the beast mode in analyzer, then share it to the dataset in order to reference it in a sumo card.
Personally i recommend you don't use the Sumo card and just use the Pivot Table card in 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
-
Hi @gbennett
Did you mean to say aggregating it doesn’t work? How does it currently work and how are you expecting it to work?
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
Hey Grant,
I would think, that if I pulled the data in a sumo card, I could group specifically on a year-month and product line and it would provide the % of Low to High. But rather it adds the % of Low to High for all records. I hope that makes sense.
I appreciate your help.
Thanks.
0 -
Given the math you've put on the screen, there is no reason to run this ETL as a SQL transform. Just keep your data unaggregated.
Be careful with
Sum(`Early to Lost`+`Early to Won`+`Early to Late`) AS 'Total Low to High'
for any row, if any column contains the value null, the entire result will be null. this is the appropriate adjustment.
Sum(ifnull(`Early to Lost`,0) +ifnull(`Early to Won`,0)+ifnull(`Early to Late`,0) ) AS 'Total Low to High'
to do the division you're describing, just calculate the ratio in a beast mode (you may have to build the beast mode in analyzer, then share it to the dataset in order to reference it in a sumo card.
Personally i recommend you don't use the Sumo card and just use the Pivot Table card in 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 -
I was able to use Sum(ifnull(`Early to Lost`,0) +ifnull(`Early to Won`,0)+ifnull(`Early to Late`,0) ) AS 'Total Low to High'
and enter in a beast mode.
0
Categories
- All Categories
- 1.7K Product Ideas
- 1.7K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 292 Workbench
- 4 Cloud Amplifier
- 8 Federated
- 2.8K Transform
- 95 SQL DataFlows
- 601 Datasets
- 2.1K Magic ETL
- 3.7K Visualize
- 2.4K Charting
- 691 Beast Mode
- 43 App Studio
- 39 Variables
- 658 Automate
- 170 Apps
- 441 APIs & Domo Developer
- 42 Workflows
- 5 DomoAI
- 32 Predict
- 12 Jupyter Workspaces
- 20 R & Python Tiles
- 385 Distribute
- 110 Domo Everywhere
- 269 Scheduled Reports
- 6 Software Integrations
- 112 Manage
- 109 Governance & Security
- 8 Domo University
- 25 Product Releases
- Community Forums
- 39 Getting Started
- 29 Community Member Introductions
- 98 Community Announcements
- Domo Community Gallery
- 4.8K Archive