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.5K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.9K Transform
- 100 SQL DataFlows
- 616 Datasets
- 2.2K Magic ETL
- 3.8K Visualize
- 2.5K Charting
- 737 Beast Mode
- 55 App Studio
- 40 Variables
- 684 Automate
- 176 Apps
- 452 APIs & Domo Developer
- 46 Workflows
- 10 DomoAI
- 35 Predict
- 14 Jupyter Workspaces
- 21 R & Python Tiles
- 394 Distribute
- 113 Domo Everywhere
- 275 Scheduled Reports
- 6 Software Integrations
- 123 Manage
- 120 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 10 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 108 Community Announcements
- 4.8K Archive