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
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 617 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 738 Beast Mode
- 58 App Studio
- 40 Variables
- 685 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 395 Distribute
- 113 Domo Everywhere
- 276 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 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