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.4K Product Ideas
- 1.4K Ideas Exchange
- 1.4K Connect
- 1.1K Connectors
- 278 Workbench
- 4 Cloud Amplifier
- 4 Federated
- 2.7K Transform
- 89 SQL DataFlows
- 557 Datasets
- 2K Magic ETL
- 3.3K Visualize
- 2.3K Charting
- 571 Beast Mode
- 11 App Studio
- 28 Variables
- 579 Automate
- 141 Apps
- 414 APIs & Domo Developer
- 23 Workflows
- 1 DomoAI
- 28 Predict
- 12 Jupyter Workspaces
- 16 R & Python Tiles
- 352 Distribute
- 92 Domo Everywhere
- 258 Scheduled Reports
- 2 Software Integrations
- 92 Manage
- 89 Governance & Security
- 9 Product Release Questions
- Community Forums
- 42 Getting Started
- 28 Community Member Introductions
- 88 Community Announcements
- 4.8K Archive