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
“There is a superhero in all of us, we just need the courage to put on the cape.” -Superman0
Categories
- 10.5K All Categories
- 6 Connect
- 916 Connectors
- 250 Workbench
- 463 Transform
- 1.7K Magic ETL
- 69 SQL DataFlows
- 476 Datasets
- 189 Visualize
- 252 Beast Mode
- 2.1K Charting
- 11 Variables
- 17 Automate
- 354 APIs & Domo Developer
- 89 Apps
- 3 Workflows
- 20 Predict
- 5 Jupyter Workspaces
- 15 R & Python Tiles
- 246 Distribute
- 62 Domo Everywhere
- 243 Scheduled Reports
- 21 Manage
- 42 Governance & Security
- 172 Product Ideas
- 1.2K Ideas Exchange
- 11 Community Forums
- 27 Getting Started
- 14 Community Member Introductions
- 55 Community News
- 4.5K Archive