Null Date Values in Card Filters
Hi!
I know this question has been asked a few times in the forums over the years (see "Best Practice for Date fields" and "How do you Filter on Date that is Null") so apologies for the redundancy. I'm asking the question again because these posts seem to miss an element that is crucial to my use case: calculations and Beast Mode functions.
I am building a KPI dashboard for a team of Project Managers. Projects are separated into 10 "milestones". Milestones and other date fields (at least 25 total but probably more) are currently being tracked within Salesforce in various custom fields. For example:Milestone_1_Due Date
Milestone_1_Completed Date
Milestone_2_Due Date
Milestone_2_Completed Date
...Milestone_10_Due Date
Milestone_10_Completed Date
Target Launch Date
Project Opened Date
Project Closed Date
Depending on where a Project Manager is within the project timeline, it's very common and expected that many of these Due Date/Completed Date values will be blank.
I'm tasked with doing a number of calculations on these projects, for example:
- "How many projects completed 'Milestone 7' at least 7 days before their
Target Launch Date
?" - "What percentage of projects launched on time?"
- etc.
In ETL, I have defined all date columns as Date data types so I can easily do math on them. However, cards prohibit null values being used in filter configuration.
I am aware of workarounds involving CASE or IFNULL for empty dates (CASE WHEN Date_Column
IS NULL THEN 'Is null' ELSE Date_Column
END) but these update the data type from Date to String, which breaks the formulas used to calculate if DateA occurred before DateB.
Are my options...:
- Duplicating the date columns so I have both data types (~50 columns instead of ~25): Date for calculations and String for filtering nulls
- Using DATE() and other String/DateTime functions in Beast Mode on an ad hoc basis
- Populating a bogus date value in MagicETL to replace null (e.g., null -> 1900/1/1)
It seems like a lot of workarounds and extra work to leverage functionality that exists in other parts of Domo (i.e. you can filter Include/Exclude in the Data view of a dataset).
Are there other best practices out there that I'm missing?
Best Answer
-
I think a best practice when dealing with a large number of fields like this is to unpivot them into a "long format" dataset rather than a super wide dataset. That helps you not have to perform the same transforms 25 times, and usually makes building cards easier, too.
Making some broad assumptions without knowing your dataset/context, my guess is you'd want to split your dataset into milestone information and project information, then unpivot the milestones and join the project information back in. That would reduce your number of date columns down to something more manageable. Something like this:
That would also facilitate filtering on stuff like "show me all the milestones reached before the target launch date", where you could make some of the that analysis more dynamic and user driver.
Please 💡/💖/👍/😊 this post if you read it and found it helpful.
Please accept the answer if it solved your problem.
0
Answers
-
I guess the path to follow would depend on what you want to do with the dates. If option 3 works for you, then there is no need to do this in ETL, you can do this in the Views Explorer and Remap Nulls to the bogus date of your choice.
Usually when a date is NULL and you operate on it the result of the operation will be NULL, which could be desired at time to indicate that the elapsed time between timestamps couldn't be calculated as it has failed to reached either of them and would usually case any CASE statement to go up to the default ELSE statement, unless you specifically check for NULL as part of your logic.
0 -
I think a best practice when dealing with a large number of fields like this is to unpivot them into a "long format" dataset rather than a super wide dataset. That helps you not have to perform the same transforms 25 times, and usually makes building cards easier, too.
Making some broad assumptions without knowing your dataset/context, my guess is you'd want to split your dataset into milestone information and project information, then unpivot the milestones and join the project information back in. That would reduce your number of date columns down to something more manageable. Something like this:
That would also facilitate filtering on stuff like "show me all the milestones reached before the target launch date", where you could make some of the that analysis more dynamic and user driver.
Please 💡/💖/👍/😊 this post if you read it and found it helpful.
Please accept the answer if it solved your problem.
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 755 Beast Mode
- 61 App Studio
- 41 Variables
- 693 Automate
- 178 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive