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.9K Product Ideas
- 1.9K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 302 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 104 SQL DataFlows
- 637 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 761 Beast Mode
- 65 App Studio
- 42 Variables
- 704 Automate
- 182 Apps
- 458 APIs & Domo Developer
- 53 Workflows
- 11 DomoAI
- 39 Predict
- 16 Jupyter Workspaces
- 23 R & Python Tiles
- 401 Distribute
- 116 Domo Everywhere
- 277 Scheduled Reports
- 8 Software Integrations
- 132 Manage
- 129 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 111 Community Announcements
- 4.8K Archive