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.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