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
- All Categories
- 1.1K Product Ideas
- 1.1K Ideas Exchange
- 1.2K Connect
- 966 Connectors
- 254 Workbench
- Cloud Amplifier
- 1 Federated
- 2.4K Transform
- 75 SQL DataFlows
- 499 Datasets
- 1.8K Magic ETL
- 2.7K Visualize
- 2.2K Charting
- 360 Beast Mode
- 19 Variables
- 481 Automate
- 101 Apps
- 376 APIs & Domo Developer
- 6 Workflows
- 22 Predict
- 6 Jupyter Workspaces
- 16 R & Python Tiles
- 316 Distribute
- 64 Domo Everywhere
- 252 Scheduled Reports
- 59 Manage
- 59 Governance & Security
- 1 Product Release Questions
- 5K Community Forums
- 37 Getting Started
- 23 Community Member Introductions
- 63 Community Announcements
- 4.8K Archive