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
 7.3K All Categories
 13 Getting Started in the Community
 141 Beastmode & Analytics
 1.8K Data Platform & Data Science
 54 Domo Everywhere
 2K Charting
 1K Ideas Exchange
 903 Connectors
 236 Workbench
 342 APIs
 77 Apps
 19 Governance & Productivity
 234 Use Cases & Best Practices
 50 News
 473 Onboarding
 572 日本支部