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 
@gbrown how are you filtering? are you filtering on each beast mode where equal to null? (I.e. 3 filters in the filter section?) Because that would filter out any rows where they are null even if the others all null and you'd only get rows where all three are not null.
1 
@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.6K Product Ideas
 1.6K Ideas Exchange
 1.4K Connect
 1.1K Connectors
 286 Workbench
 4 Cloud Amplifier
 6 Federated
 2.7K Transform
 91 SQL DataFlows
 585 Datasets
 2.1K Magic ETL
 3.6K Visualize
 2.4K Charting
 641 Beast Mode
 34 App Studio
 33 Variables
 628 Automate
 159 Apps
 430 APIs & Domo Developer
 37 Workflows
 2 DomoAI
 31 Predict
 12 Jupyter Workspaces
 19 R & Python Tiles
 378 Distribute
 107 Domo Everywhere
 266 Scheduled Reports
 5 Software Integrations
 104 Manage
 101 Governance & Security
 6 Domo University
 15 Product Releases
 Community Forums
 40 Getting Started
 30 Community Member Introductions
 93 Community Announcements
 4.8K Archive