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!**0 -
Could you explain how that works? Not sure what you mean.
0 -
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
- 7.7K All Categories
- 5 Connect
- 921 Connectors
- 244 Workbench
- 477 Transform
- 1.8K Magic ETL
- 60 SQL DataFlows
- 446 Datasets
- 40 Visualize
- 199 Beast Mode
- 2K Charting
- 8 Variables
- 1 Automate
- 348 APIs & Domo Developer
- 82 Apps
- Workflows
- 14 Predict
- 3 Jupyter Workspaces
- 11 R & Python Tiles
- 241 Distribute
- 59 Domo Everywhere
- 241 Scheduled Reports
- 15 Manage
- 36 Governance & Security
- 28 Product Ideas
- 1.1K Ideas Exchange
- Community Forums
- 14 Getting Started
- 1 Community Member Introductions
- 49 Community News
- 18 Event Recordings
- 579 日本支部