How do I create a MoM variance formula when the date format and interval varies for all entries?

Here is a sample data, where F11 is for month of November, F10 is for month of October-
Best Answers
-
I would start by standardizing the date variable. You could use str_to_date:
CASE
WHEN left(`Date`,1) = 'F' then str_to_date( concat(`Date`,2023), 'F%c%Y')
ELSE str_to_date(
Date
, '%d-%b-%y')END
Here's an article on different date transforms:
And the different codes for date formats:
Please 💡/💖/👍/😊 this post if you read it and found it helpful.
Please accept the answer if it solved your problem.
0 -
Can you describe in plain words what you expect the above formula to do? At a Row level the MAX(
Col
) of something is always going to be the same value asCol
making your denominator to always be 0, causing an error and therefore displaying no data.To fix this you'll need to have some sort of aggregation function around your values, providing a table or image that illustrates what the desired final outcome would be is often helpful. If is just a single value for the current month this might be achievable (or the latest month), but if you want a table that shows this on a monthly basis, it's likely you might want to leverage Magic ETL instead.
1
Answers
-
I would start by standardizing the date variable. You could use str_to_date:
CASE
WHEN left(`Date`,1) = 'F' then str_to_date( concat(`Date`,2023), 'F%c%Y')
ELSE str_to_date(
Date
, '%d-%b-%y')END
Here's an article on different date transforms:
And the different codes for date formats:
Please 💡/💖/👍/😊 this post if you read it and found it helpful.
Please accept the answer if it solved your problem.
0 -
I standardized the date and next I tried this formula to give variance but it's not giving me any value. Any idea what I might be doing wrong here?
CASE
whenAccount
= 'Sales' then
((CASE WHEN MONTH(Date
) = MAX(MONTH(Date
)) THEN SUM(Sales
) END) -
(CASE WHEN MONTH(Date
) = MAX(MONTH(Date
))-1 THEN SUM(Sales
) END))
/
(CASE WHEN MONTH(Date
) = MAX(MONTH(Date
))-1 THEN SUM(Sales
) END)
else 0
ENDAppreciate your help, thanks!
0 -
Can you describe in plain words what you expect the above formula to do? At a Row level the MAX(
Col
) of something is always going to be the same value asCol
making your denominator to always be 0, causing an error and therefore displaying no data.To fix this you'll need to have some sort of aggregation function around your values, providing a table or image that illustrates what the desired final outcome would be is often helpful. If is just a single value for the current month this might be achievable (or the latest month), but if you want a table that shows this on a monthly basis, it's likely you might want to leverage Magic ETL instead.
1
Categories
- All Categories
- Product Ideas
- 2.1K Ideas Exchange
- Connect
- 1.3K Connectors
- 309 Workbench
- 7 Cloud Amplifier
- 10 Federated
- Transform
- 664 Datasets
- 120 SQL DataFlows
- 2.3K Magic ETL
- 825 Beast Mode
- Visualize
- 2.6K Charting
- 90 App Studio
- 46 Variables
- Automate
- 197 Apps
- 489 APIs & Domo Developer
- 94 Workflows
- 24 Code Engine
- AI and Machine Learning
- 23 AI Chat
- 4 AI Projects and Models
- 18 Jupyter Workspaces
- Distribute
- 119 Domo Everywhere
- 283 Scheduled Reports
- 11 Software Integrations
- Manage
- 145 Governance & Security
- 12 Domo Community Gallery
- 49 Product Releases
- 13 Domo University
- Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 116 Community Announcements
- 5K Archive