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.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 738 Beast Mode
- 56 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 123 Manage
- 120 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