Grouping into one Row

I want to be able to group the parent_wID field so that it is one row per entry. As you can see, the Retail/Wholesale columns are build from beast modes from a separate field. This is the syntax i used to separate those.
"Retail"
(CASE
when `Loan_Originator_Type` = 'Retail' THEN 'Yes'
else 0
end)
"Wholesale"
(CASE
when `Loan_Originator_Type` = 'Wholesale' THEN 'Yes'
else 0
end)
Unfortunately this spits out multiple rows, but I would like to aggregate and group everything into just the parent_wID.
Best Answer
-
"Retail" MAX(CASE when `Loan_Originator_Type` = 'Retail' THEN 'Yes' else 0 end) "Wholesale" MAX(CASE when `Loan_Originator_Type` = 'Wholesale' THEN 'Yes' else 0 end)
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1
Answers
-
Hi @user063136
A quick hack would be to aggregate these columns in Analyzer with a max() function which would cause Yes to override your 0 value. This is assuming the rest of the data you're displaying isn't unique or it's aggregated.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
Could you explain how that works? Not sure what you mean.
0 -
"Retail" MAX(CASE when `Loan_Originator_Type` = 'Retail' THEN 'Yes' else 0 end) "Wholesale" MAX(CASE when `Loan_Originator_Type` = 'Wholesale' THEN 'Yes' else 0 end)
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**1 -
oh that worked thank you so much!
0 -
@GrantSmith and @user063136 ,
judging from the results of your original post it looks like, for one parentID there can be both Retail and Wholsale loan originator types. If that weren't the case, then you shouldn't get multiple rows per parent.
"Retail"
(CASE
when `Loan_Originator_Type` = 'Retail' THEN 'Yes'
else 0end)
"Wholesale"
(CASE
when `Loan_Originator_Type` = 'Wholesale' THEN 'Yes'
else 0end)
Given that you only want ONE response, I would put my aggregation INSIDE the CASE statement.
CASE
WHEN SUM (CASE WHEN LoanType = 'retail' THEN 1 else 0 END) > 0 THEN 'Retail'
END
Why is this better? Improved transparency and increased code recycling
With MAX(CASE ...) you can't answer the follow-up question: "how many retail loans are there" with the same logic. You might say, "but Jae each parent only has 1 loan originator." that may be true, but when i roll my data up to a higher level of aggregation, i want to build logic that still works.
By starting with SUM(CASE WHEN 'retail' then 1 else 0 end) as the base metric, i can validate (without hacks) the assumptions about my data AND aggregate reliably to different levels.
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"0
Categories
- All Categories
- 2K Product Ideas
- 2K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 311 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3.8K Transform
- 656 Datasets
- 115 SQL DataFlows
- 2.2K Magic ETL
- 811 Beast Mode
- 3.3K Visualize
- 2.5K Charting
- 80 App Studio
- 45 Variables
- 771 Automate
- 190 Apps
- 481 APIs & Domo Developer
- 77 Workflows
- 23 Code Engine
- 36 AI and Machine Learning
- 19 AI Chat
- AI Playground
- AI Projects and Models
- 17 Jupyter Workspaces
- 410 Distribute
- 120 Domo Everywhere
- 280 Scheduled Reports
- 10 Software Integrations
- 142 Manage
- 138 Governance & Security
- 8 Domo Community Gallery
- 48 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 114 Community Announcements
- 4.8K Archive