Sum distinct
Hi, i have dataset of products that have repetition item code and quantity, how do i sum the quantity?
Answers
-
There are a number of ways to handle this, but the easiest might be to simply use MAX or AVG rather than SUM
0 -
Using fixed functions!
If I solved your problem, please select "yes" above
1 -
SUM(`quantity` / SUM(1) FIXED (BY `product_id`))
Use a fixed function to determing the number of records you have for each product, divide the quantity by that to get fractional quantity and then SUM it all together to get the overall quantity.
**Was this post helpful? Click Agree or Like below**
**Did this solve your problem? Accept it as a solution!**0 -
Thank you for the feedback. However, when I compare it to an excel file, I still do not get the same answer.
For the record, the duplication occurs annually. Please help.
0 -
Assuming your data looks kind of like this, where the same product qty is repeated within a year
then this beast mode will dedupe and sum by product and year:
SUM(MAX(`qty`) FIXED (by `product`,`year`))
0 -
I am still receiving different quantities, the correct amount shown in the Excel picture above...
0 -
Hi - when an item code is repeated, is the qty always the same corresponding value?
0 -
Yes, but it can be different items as well…😓
0 -
in excel I'm using this DAX code :
SUMX(DISTINCT('Master Data'[LR_YR_art]),CALCULATE(DISTINCT('Master Data'[Soh CDC Current QTY])))0 -
The DISTINCT expression in your DAX code is going to return a deduped list of qty values correct? Let's say for example, two items A & B both have a qty of 5, wouldn't the DAX code give you a total of 5 rather than 10? I don't know DAX so I want to make sure I'm interpreting that correctly.
0 -
Two distinct items will be used to calculate both items A and B. It will, of course, display two distinct totals.
Here is the example (in simple excel) :
Year
Product
Quantity
2022
a
300
2022
a
300
2022
b
500
2022
c
800
2022
a
300
Total
2200
Total year 2022
: 1600
not 2200 because item "a" is repeating 3 times
0 -
Using the example data you provided I am getting a deduped SUM of 1,600 using the beast mode I provided earlier, if I add a total row it also evaluates to 1,600. Not sure why it isn't working for you.
Going back to my earlier question, I'm curious what your DAX calculation would evaluate to if you were to add a Product D that has a quantity of 300, 500, or 800?
0
Categories
- All Categories
- 1.7K Product Ideas
- 1.7K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 296 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 98 SQL DataFlows
- 611 Datasets
- 2.1K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 717 Beast Mode
- 52 App Studio
- 40 Variables
- 671 Automate
- 171 Apps
- 448 APIs & Domo Developer
- 45 Workflows
- 7 DomoAI
- 34 Predict
- 14 Jupyter Workspaces
- 20 R & Python Tiles
- 391 Distribute
- 111 Domo Everywhere
- 274 Scheduled Reports
- 6 Software Integrations
- 118 Manage
- 115 Governance & Security
- Domo Community Gallery
- 32 Product Releases
- 9 Domo University
- 5.3K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 104 Community Announcements
- 4.8K Archive