SUM for sales when there are multiple prices
We have a few places that we receive pricing for a product, so to account for it in our sales beastmode I have been using the below formula but it sometimes provides numbers much greater than the equation should provide. An example would be a quantity of one * a price of 32 has (incredibly infrequently) given a price hundreds of times larger.
The beastmode is written in order of importance, and if the unit_price exists we would want to ignore the other options, but if it doesnt exist I want it to check for alternative_unit_price, etc.
Am I missing something? Is there a better way to write the beastmode, or a more elegant solution? Any feedback appreciated!
SUM(((CASE when `unit_price`>0 then `unit_price`
when `alternative_unit_price`>0 then `alternative_unit_price`
when `backup_unit_price`>0 then `backup_unit_price`
else 0 end)
*`unit_quantity`)
+
((CASE when `case_price`>0 then `case_price`
when `alternative_case_price`>0 then `alternative_case_price`
when `backup_case_price`>0 then `backup_case_price`
else 0 end)
*`case_quantity`))
Comments
-
I don’t think you need the sum() part. Drop the sum and just use the + sign
0
Categories
- All Categories
- 1.9K Product Ideas
- 1.9K Ideas Exchange
- 1.6K Connect
- 1.3K Connectors
- 306 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3K Transform
- 112 SQL DataFlows
- 649 Datasets
- 2.2K Magic ETL
- 4K Visualize
- 2.5K Charting
- 788 Beast Mode
- 78 App Studio
- 43 Variables
- 745 Automate
- 187 Apps
- 475 APIs & Domo Developer
- 67 Workflows
- 16 DomoAI
- 40 Predict
- 17 Jupyter Workspaces
- 23 R & Python Tiles
- 406 Distribute
- 117 Domo Everywhere
- 279 Scheduled Reports
- 10 Software Integrations
- 139 Manage
- 136 Governance & Security
- 8 Domo Community Gallery
- 44 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 41 Getting Started
- 31 Community Member Introductions
- 113 Community Announcements
- 4.8K Archive