Using Variables to Pick "Closest Date"
Hey! I wasn't sure if this went in Variables or Beast Mode questions. I have data that is currently structured:
Opp Name - Value - Date Updated
A - 100 - 3/15
A - 80 - 3/30
A - 120 - 4/5
B - 50 - 4/1
B - 75 - 4/7
The outcome I'm looking for is for a User to be able to input a Date (say 4/1) as a Variable and then have the dataset filter down to the closest Date Updated w/o going over for each Opp Name (3/30 for A, 4/1 for B). I've tried using a combo of a Variable and RANK() (along the lines of RANK() OVER(Partition BY 'Opp Name' Order BY DATEDIFF('Variable','Date Updated') and then filtering to Rank = 1 … but whenever i put this into a Bar Chart that tries to Aggregate the Value for some reason the Rank filter isn't taking and it's just Summing everything. I know it's risky/sketchy to use Window Functions as filters, and that might be causing the issue, so does anyone have any ideas of how to accomplish what i'm looking for?
TLDR version: I'm looking for a way get Total Value of all Opps on any given day as selected by the end user w/o bumping a calendar of every single day into my dataset because that would make the dataset waaaaay too large. Appreciate any help.
Answers
-
Have you tried something like:
CASE WHEN (`Variable`-`Date Updated`) = MIN(CASE WHEN `Date Updated` <= `Variable` THEN `Variable`-`Date Updated` END) OVER (PARTITION BY `Opp Name`) THEN 'Closest' ELSE 'Exclude' END
And filtering on the beast mode = Closest?
Regarding your beast mode do you have any aggregation that's being performed on the card?
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**2 -
@GrantSmith I appreciate the quick response! This is a nice way to get around RANK() … however, I tried this and it still seems to be summing everything… which i guess to answer your question, yes, I am summing the Value field as the Y-Axis so there is an aggregation in my final chart. I'm not sure if that is what is throwing off the Beast Mode filter… i've attached a few screenshots of what i'm seeing. Appreciate your response to this!
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 738 Beast Mode
- 57 App Studio
- 40 Variables
- 685 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 124 Manage
- 121 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive