Sum distinct
Hi, i have dataset of products that have repetition item code and quantity, how do i sum the quantity?
Best Answers
-
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?
1 -
Hi - I shared a beast mode that you can use in a card, not an ETL
0
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?
1 -
Is this in beast mode or in ETL?
0 -
Hi - I shared a beast mode that you can use in a card, not an ETL
0 -
Ok. Done it. Great!. Thank you very much yeahhhh 😁
1
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive