CASE statement if else Magic ETL
Hey guys I am trying to fill a column based on certain criteria from 4 columns.
I think it would be best to do this in another column so that I'm not overwriting anything.
My table looks like the following and I'm trying a Case Statement that fills in the null spaces, but I think my case statement is missing something or I'm missing a step.
My case statement looks like this so far:
CASE when `date_created`=`date_updated` and `time_created`=`time_updated` and `publish_date` IS NULL then `date_created` else `publish_date` end
Unfortunately my case statement sucks and this doesn't work to my advantage.
Can anyone help?
You didn't clearly state what exactly your issue was with your beast mode so I'm somewhat guessing here but you're essentially wanting to use the most recent date between publish date and update date for the publish date if the publish date is null correct?
If that's correct then you have two independent conditions dependent upon each other. Essentially you're saying the dates must be the same and publish date must be null in order for you to use the creation date. I'm assuming here too that your creation date and updated date will be the same when an entry is created. With those assumptions you can just narrow down your beast mode to using the updated date if the publish date is null.
Simplifies down to:
IFNULL(`publish_date`, `date_updated`)**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0
a series of nested IFNULL statements will get the job done as per Grant's recommendation, but have a look at COALESCE() it will return the first non null value in a chain.
if you want to write it as a case statement then do a series of null checks
when colA is not null then colA
when colB is not null then colB
when colC is not null then colC
by definition you don't need to build extensive logic b/c in order for the second clause (test for to apply, colA must have been null (otherwise the preceeding logic step would have applied).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
- 10.5K All Categories
- 8 Connect
- 918 Connectors
- 250 Workbench
- 467 Transform
- 1.7K Magic ETL
- 69 SQL DataFlows
- 477 Datasets
- 193 Visualize
- 252 Beast Mode
- 2.1K Charting
- 11 Variables
- 80 Cards, Dashboards, Stories
- 17 Automate
- 354 APIs & Domo Developer
- 89 Apps
- 3 Workflows
- 20 Predict
- 5 Jupyter Workspaces
- 15 R & Python Tiles
- 246 Distribute
- 62 Domo Everywhere
- 243 Scheduled Reports
- 21 Manage
- 42 Governance & Security
- 173 Product Ideas
- 1.2K Ideas Exchange
- 12 Community Forums
- 27 Getting Started
- 14 Community Member Introductions
- 55 Community News
- 4.5K Archive