Sales Revenue Ranking by dynamic date and limit pivot rows
Hello,
I am trying to get a pivot table card in Domo and it could show sales revenue by different categories and reporting date. More importantly, I hope to rank the categories by total sales revenue within a specific time and the card could only show the top N categories' records. Within a different period of time, the total sales revenue in different categories will vary, then the top N would change accordingly.
Here is an example. I want to choose the top 2 categories (based on total revenue) by sales revenue and date and set ReportingDate as a filter.
the dataset
Category | SubCategory | ReportingDate | Sales |
A | a | 2020-11 | 200 |
A | b | 2020-11 | 300 |
A | c | 2020-11 | 100 |
A | a | 2020-10 | 100 |
A | b | 2020-10 | 200 |
B | d | 2020-11 | 150 |
B | d | 2020-10 | 350 |
B | e | 2020-11 | 100 |
B | e | 2020-10 | 400 |
C | f | 2020-11 | 150 |
C | f | 2020-10 | 200 |
C | g | 2020-11 | 300 |
C | g | 2020-10 | 100 |
C | h | 2020-11 | 210 |
C | h | 2020-10 | 250 |
Here is the result:
If includes all-time, top 2 would be C and B; If the filter in reporting 2020-10, top 2 would be B and C; If the filter in reporting 2020-11, top 2 would be C and A.
Category | 2020-10 | 2020-11 | Sum |
C | 550 | 660 | 1210 |
B | 750 | 250 | 1000 |
A | 300 | 600 | 900 |
Thank you!
Comments
-
here's a pretty extensive tutorial on window functions. https://www.youtube.com/watch?v=eifSYZIcPzg
you can't filter on a rank in window functions. but you can set the data row limit to 2 or 5 or 10 rows and sort by sum(Amount) desc which is functionally the same thing.
in your case if you have months on an axis, to get total for the year you'd write
sum(sum(amount)) over (partition by category)
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"0 -
Thanks for your help. I followed your instructions and everything is good before I limited rows. I had a 13-month data in the pivot table in Domo with setting category as the x-axis and reporting date as the y-axis. After I limit rows to 30 (I have 4-5K rows originally), the table only shows the data in the latest reporting date, the other data would disappear. I attached two images to show how it looks like before and after I limit rows to 30.
Do you have a general idea about why it happened?
Really appreciate your help!
0 -
If you're using a pivot table with months on the axis, your data set is no longer 3 rows, it'll be around 3(categories) * 12(months) assuming you have data in each month...
in other words, it gets weird. so don't use a pivot table if you want to limit rows that way. instead build a beast mode for each month.
Jae Wilson
Check out my 🎥 Domo Training YouTube Channel 👨💻
**Say "Thanks" by clicking the ❤️ in the post that helped you.
**Please mark the post that solves your problem by clicking on "Accept as Solution"1
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
- 101 SQL DataFlows
- 622 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 747 Beast Mode
- 59 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
- 125 Manage
- 122 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