I am trying to calculate the difference between values in the same column on 2 different dates
I only have 3 dimensions and one measure.
Dimensions:
Date
Category
Company
Measure:
Category Rank
I am trying to create a calculated field based on Rank, that tells me the difference month over month. I thought I'd be able to find a calculation in beast mode for different, but am not. If anyone can help me with a calculation that will tell me the difference in Category Rank Month over month that would be fantastic.
Answers
-
Hi @user03781
Have you tried using a LAG or LEAD window function? They'll get you the value from the row before or after respective
You can then take the rank difference between the two dates.
I did a write up on them here: https://dojo.domo.com/discussion/52679/domo-ideas-conference-beast-modes-rolling-averages
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**2 -
Hi,
I'm facing a similar issue. In my case, I wanted to see the difference between two dates in the same column. I have a Rank column also. I have used the beast mode calculation as
(Case when 'rank' = 2 then 'date' end) - (Case when 'rank' = 1 then 'date' end)
But this is not giving any data, the output is just blank. Let me know, if any solution are there?
Thanks
0 -
Hi @Salmas
Beast modes are evaluated on a row basis and typically don't know of other rows. So in your case it won't ever see a row with rank 1 if it's on the row of rank 2. When you subtract NULL from something the ending result is NULL which is why you have blank output.
You'd need to use the LAG (prior) or LEAD (next) function to get the appropriate value you want to evaluate. Make sure you order your data correctly with your lag/lead function otherwise you'll get unexpected results.
Here's a post I did on rolling average which might give you some additional insight into how LAG/LEAD work.
Domo IDEAs Conference - Beast Modes - Rolling Averages
If you don't have access to the LAG and LEAD functions in a beast mode you might need to talk with your CSM to get it enabled.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**2 -
@Salmas i would try using datediff instead of minus (-) operand. That might work.
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
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 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