Filtering null values on a card
I have beastmodes to calculate change in margin over years and I am trying to filter out when all three columns are null to keep only active fields. ( If one column has a change then all three columns should show) only filter when all three are null.
I made a beastmode but it seems to be giving me some trouble.
Answers

They are fairly long which could be causing the issue...
Change in Margin  2020 to 2021:
(SUM(CASE WHEN YEAR(`Period Date.1`) = YEAR(SUBDATE(CURDATE(), interval 1 year)) AND MONTH(`Period Date.1`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date.1`) < DAYOFYEAR(CURDATE()) THEN `Net Sales Amount` END)

SUM(CASE WHEN YEAR(`Period Date`) = YEAR(SUBDATE(CURDATE(), interval 1 year)) AND MONTH(`Period Date`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date`) < DAYOFYEAR(CURDATE()) THEN `Amount` END))
/
SUM(CASE WHEN YEAR(`Period Date.1`) = YEAR(SUBDATE(CURDATE(), interval 1 year)) AND MONTH(`Period Date.1`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date.1`) < DAYOFYEAR(CURDATE()) THEN `Net Sales Amount` END)

(SUM(CASE WHEN YEAR(`Period Date.1`) = YEAR(SUBDATE(CURDATE(), interval 2 year)) AND MONTH(`Period Date.1`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date.1`) < DAYOFYEAR(CURDATE()) THEN `Net Sales Amount` END)

SUM(CASE WHEN YEAR(`Period Date`) = YEAR(SUBDATE(CURDATE(), interval 2 year)) AND MONTH(`Period Date`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date`) < DAYOFYEAR(CURDATE()) THEN `Amount` END))
/
SUM(CASE WHEN YEAR(`Period Date.1`) = YEAR(SUBDATE(CURDATE(), interval 2 year)) AND MONTH(`Period Date.1`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date.1`) < DAYOFYEAR(CURDATE()) THEN `Net Sales Amount` END)
Change in Margin  2021 to 2022:
((CASE WHEN `Net Sales`= 'Net Sales' THEN SUM(CASE WHEN YEAR(`Period Date`) = YEAR(SUBDATE(CURDATE(), interval 1 day)) AND MONTH(`Period Date`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date`) <= DAYOFYEAR(CURDATE()) THEN `Net Sales Amount` END) END)

(CASE WHEN `cost type`= 'COGS' THEN SUM(CASE WHEN YEAR(`Period Date`) = YEAR(SUBDATE(CURDATE(), interval 1 day)) AND MONTH(`Period Date`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date`) <= DAYOFYEAR(CURDATE()) THEN `Amount` END) END))
/
(CASE WHEN `Net Sales`= 'Net Sales' THEN SUM(CASE WHEN YEAR(`Period Date`) = YEAR(SUBDATE(CURDATE(), interval 1 day)) AND MONTH(`Period Date`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date`) <= DAYOFYEAR(CURDATE()) THEN `Net Sales Amount` END) END)

(SUM(CASE WHEN YEAR(`Period Date.1`) = YEAR(SUBDATE(CURDATE(), interval 1 year)) AND MONTH(`Period Date.1`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date.1`) < DAYOFYEAR(CURDATE()) THEN `Net Sales Amount` END)

SUM(CASE WHEN YEAR(`Period Date`) = YEAR(SUBDATE(CURDATE(), interval 1 year)) AND MONTH(`Period Date`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date`) < DAYOFYEAR(CURDATE()) THEN `Amount` END))
/
SUM(CASE WHEN YEAR(`Period Date.1`) = YEAR(SUBDATE(CURDATE(), interval 1 year)) AND MONTH(`Period Date.1`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date.1`) < DAYOFYEAR(CURDATE()) THEN `Net Sales Amount` END)
Change in Margin  2020 to 2022:
((CASE WHEN `Net Sales`= 'Net Sales' THEN SUM(CASE WHEN YEAR(`Period Date`) = YEAR(SUBDATE(CURDATE(), interval 1 day)) AND MONTH(`Period Date`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date`) <= DAYOFYEAR(CURDATE()) THEN `Net Sales Amount` END) END)

(CASE WHEN `cost type`= 'COGS' THEN SUM(CASE WHEN YEAR(`Period Date`) = YEAR(SUBDATE(CURDATE(), interval 1 day)) AND MONTH(`Period Date`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date`) <= DAYOFYEAR(CURDATE()) THEN `Amount` END) END))
/
(CASE WHEN `Net Sales`= 'Net Sales' THEN SUM(CASE WHEN YEAR(`Period Date`) = YEAR(SUBDATE(CURDATE(), interval 1 day)) AND MONTH(`Period Date`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date`) <= DAYOFYEAR(CURDATE()) THEN `Net Sales Amount` END) END)

(SUM(CASE WHEN YEAR(`Period Date.1`) = YEAR(SUBDATE(CURDATE(), interval 2 year)) AND MONTH(`Period Date.1`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date.1`) < DAYOFYEAR(CURDATE()) THEN `Net Sales Amount` END)

SUM(CASE WHEN YEAR(`Period Date`) = YEAR(SUBDATE(CURDATE(), interval 2 year)) AND MONTH(`Period Date`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date`) < DAYOFYEAR(CURDATE()) THEN `Amount` END))
/
SUM(CASE WHEN YEAR(`Period Date.1`) = YEAR(SUBDATE(CURDATE(), interval 2 year)) AND MONTH(`Period Date.1`) <= MONTH(SUBDATE(CURDATE(), interval 1 day)) AND DAYOFYEAR(`Period Date.1`) < DAYOFYEAR(CURDATE()) THEN `Net Sales Amount` END)
0 
@mhouston I did a test with this beast mode and the logic seemed to work as expected so I think you are on the right track. It is essentially the same is as what you described but without the actual margin calculations.
case when `margin1` is null and `margin2` is null and `margin3` is null then 'filter out' else 'keep' end
It may be worth rebuilding the query again to make sure that it was compiled correctly. You should be able to plug in the margin calcs into the parenthesis below and try it.
case when (20202021 code here) is null and (20212022 code here) is null and (20202022 code here) is null then 'filter out' else 'keep' end
**Say “Thanks" by clicking the thumbs up 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.7K Product Ideas
 1.7K Ideas Exchange
 1.5K Connect
 1.2K Connectors
 292 Workbench
 4 Cloud Amplifier
 8 Federated
 2.8K Transform
 95 SQL DataFlows
 603 Datasets
 2.1K Magic ETL
 3.7K Visualize
 2.4K Charting
 697 Beast Mode
 43 App Studio
 39 Variables
 658 Automate
 170 Apps
 441 APIs & Domo Developer
 42 Workflows
 5 DomoAI
 32 Predict
 12 Jupyter Workspaces
 20 R & Python Tiles
 386 Distribute
 111 Domo Everywhere
 269 Scheduled Reports
 6 Software Integrations
 113 Manage
 110 Governance & Security
 8 Domo University
 30 Product Releases
 Community Forums
 40 Getting Started
 30 Community Member Introductions
 98 Community Announcements
 Domo Community Gallery
 4.8K Archive