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.2K Product Ideas
 1.2K Ideas Exchange
 1.3K Connect
 1.1K Connectors
 273 Workbench
 2 Cloud Amplifier
 3 Federated
 2.7K Transform
 78 SQL DataFlows
 525 Datasets
 2.1K Magic ETL
 2.9K Visualize
 2.2K Charting
 434 Beast Mode
 22 Variables
 513 Automate
 115 Apps
 390 APIs & Domo Developer
 8 Workflows
 26 Predict
 10 Jupyter Workspaces
 16 R & Python Tiles
 332 Distribute
 77 Domo Everywhere
 255 Scheduled Reports
 66 Manage
 66 Governance & Security
 1 Product Release Questions
 Community Forums
 40 Getting Started
 26 Community Member Introductions
 68 Community Announcements
 4.8K Archive