Showing some values based on SUM, other values based on the most recent date available for the week?
I am working with a dataset that pulls in sales and inventory data for items on a daily basis. In data analyzer, I created a table with the data grouped by week. After grouping by week, most of the fields in my card (i.e. Revenue, Units Sold, etc.) are aggregated by SUM because I would like to know the sum of all of the daily values for the week.
There are other fields (i.e. Current Inventory On Hand, Inventory In Transit, etc.) where I would only like to show the value from the most recent date in each given week. If I aggregated these fields by SUM, the output is incorrect. If I aggregate these fields by "No aggregation", the data expands to show the daily amount for each day of the week.
Can anyone please tell me how I can show some fields as SUM and others as the most recent date available in an aggregated week? Can it be done through a beast mode? Magic ETL?
I attached an Excel document with sample data and a desired output for reference.
Best Answer
-
@Stemiller Do you have a field in your dataset that flags the most recent date or would the most recent date always be today/yesterday/etc.? If so you could aggregate your snapshot data in a beast mode like this:
max(case when
Date
= CURRENT_DATE() thenInventory on Hand
or
max(case when
Last Date Flag
= 1 thenInventory on Hand
2
Answers
-
@Stemiller Do you have a field in your dataset that flags the most recent date or would the most recent date always be today/yesterday/etc.? If so you could aggregate your snapshot data in a beast mode like this:
max(case when
Date
= CURRENT_DATE() thenInventory on Hand
or
max(case when
Last Date Flag
= 1 thenInventory on Hand
2 -
I combined your formulas and changed them slightly and it worked for me. Thank you so much!
max(CASE
whenDate
= (Current_Date())-1 thenInventory On Hand
when (Date
+ DateDiff(Date
,Max Date
)) =Max Date
thenInventory On Hand
end)0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 620 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 742 Beast Mode
- 58 App Studio
- 41 Variables
- 686 Automate
- 176 Apps
- 453 APIs & Domo Developer
- 47 Workflows
- 10 DomoAI
- 36 Predict
- 15 Jupyter Workspaces
- 21 R & Python Tiles
- 395 Distribute
- 113 Domo Everywhere
- 276 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