When x is null and y and z is not null then case statement - multiple parameters
Hey there I'm trying to perform a case statement in magic etl using the formula widget.
I'm trying to use automl tool to predict the likelihood of receiving a like, comment, and/or shares based on a section topic.
I'm not sure if I'm on the right path though.
(CASE
WHEN `likes` IS NOT NULL AND `comments` OR `shares` IS NULL THEN "likes"
WHEN `comments` IS NOT NULL AND `likes` OR `shares` IS NULL THEN "comments"
WHEN `shares` IS NOT NULL AND `comments` OR `likes` IS NULL THEN "shares"
WHEN `likes` IS NULL AND `comments` OR `shares` IS NOT NULL THEN "likes, shares"
WHEN `shares` IS NULL AND `likes` OR `comments` IS NOT NULL THEN "likes, comments"
WHEN `comments` IS NULL OR `likes` OR `shares` IS NOT NULL THEN "comments, shares"
WHEN `comments` AND `likes` AND `shares` IS NOT NULL THEN "likes,comments,shares"
WHEN `comments` AND `likes` AND `shares` IS NULL THEN "none"
ELSE 0
END
)
Best Answer
-
(CASE
WHEN `likes` IS NOT NULL AND `comments` IS NULL AND `shares` IS NULL THEN likes
WHEN `comments` IS NOT NULL AND `likes` IS NULL AND `shares` IS NULL THEN comments
WHEN `shares` IS NOT NULL AND `comments` IS NULL AND `likes` IS NULL THEN shares
WHEN `comments` IS NOT NULL AND `likes` IS NOT NULL AND `shares` IS NULL THEN comments/likes
WHEN `comments` IS NOT NULL AND `shares` IS NOT NULL AND `likes` IS NULL THEN comments/shares
WHEN `shares` IS NOT NULL AND `likes` IS NOT NULL AND `comments` IS NULL THEN shares/likes
ELSE 0
END
)0
Answers
-
(CASE
WHEN `likes` IS NOT NULL AND `comments` IS NULL AND `shares` IS NULL THEN likes
WHEN `comments` IS NOT NULL AND `likes` IS NULL AND `shares` IS NULL THEN comments
WHEN `shares` IS NOT NULL AND `comments` IS NULL AND `likes` IS NULL THEN shares
WHEN `comments` IS NOT NULL AND `likes` IS NOT NULL AND `shares` IS NULL THEN comments/likes
WHEN `comments` IS NOT NULL AND `shares` IS NOT NULL AND `likes` IS NULL THEN comments/shares
WHEN `shares` IS NOT NULL AND `likes` IS NOT NULL AND `comments` IS NULL THEN shares/likes
ELSE 0
END
)0 -
ummm... it might be important to define what you want more specifically... Auto ML can only take you so far right?
THink about what it would take if you had to do this by hand ... what would it look like? Let's break your problem down into plain Enlgish.
Let's say we were looking at brands of makeup and i want to know, if i mention x brand, will it get likes, shares and comments? This is CLASSIFICATION (a google-able term) and ideally, the answer would be a 1 or a 0 with an indicator of how confident i am in my guess.
If i made you do this by hand, you'd take all the things that mention Sephora, you'd compare how often it got a like against all the rows. If you got 55 likes / 100 rows, you'd assume, most of the time if i mention Sephora i'll get a like.
Conversely, if you had 30 likes out of 100 rows regarding Hot Topic, you'd assume, "If i mention hot topic i probably won't get a like (7 out of 10 times)
This question of "will i get a like" is completely separate from the question of "will i get a share or a comment." UNLESS your question is "If you are Sephora AND you got a Like will you get a Share"
With that in mind, i guess what i'm getting to is, even though your code works, you probably don't want to collapse your metric into one column using a CASE statement.
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.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive