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
- 305 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 3K Transform
- 106 SQL DataFlows
- 646 Datasets
- 2.2K Magic ETL
- 4K Visualize
- 2.5K Charting
- 774 Beast Mode
- 75 App Studio
- 43 Variables
- 728 Automate
- 186 Apps
- 467 APIs & Domo Developer
- 61 Workflows
- 14 DomoAI
- 40 Predict
- 17 Jupyter Workspaces
- 23 R & Python Tiles
- 403 Distribute
- 117 Domo Everywhere
- 277 Scheduled Reports
- 9 Software Integrations
- 136 Manage
- 133 Governance & Security
- 8 Domo Community Gallery
- 44 Product Releases
- 12 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 112 Community Announcements
- 4.8K Archive