Forum Discussion
DAX SUM HELP
Ho can I calculate the sum of Qty in GRN. QTy in GRN is repeating for each line item, but i need to take the value once per each document no.
Please help on this?
Hi Anonymous ,
You can use the measure below:
Measure 2 = CALCULATE ( SUMX ( SUMMARIZE ( 'Table (2)', 'Table (2)'[No_], "total", SUMX ( DISTINCT ( 'Table (2)'[Qty_ in Gen] ), 'Table (2)'[Qty_ in Gen] ) ), [total] ), FILTER ( 'Table (2)', 'Table (2)'[QC Result] = "Accepted without Deviation" ) )Best Regards,
Kelly
14 Replies
- RobbeVL
Impactful Individual
Hi there,
What is your expected result?
The easiest way to solve your problem is to take the Average, instead of the sum.
This way, the total will be the same number per Item.
Let me know if this helped.
Robbe
- AnonymousNot applicable
Not possible, its showing wrong data with conditions.
- RobbeVL
Impactful Individual
Hi,
What is your expected result ?
Robbe
- AnthonyTilley
Solution Sage
If the value is always correct in line one for each document are you able to use a calculate sum and filter to line 1
Measure = CALCULATE(SUM('Table'[QTY_in GRN]),FILTER('Table','Table'[Line NO_]=10000)) - amitchandak
Super User
Try. First one requires two measures
MAx Grn = max(Qty_in_grn) Grn sum = sumx(values(table[No_]),[MAx Grn]) Or Grn sum = sumx(summarize(table,"_grn",max(Qty_in_grn)),[_grn])Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners/ba-p/890814
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p/881739
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601 - v-kelly-msft
Community Support
Hi Anonymous ,
If the value of Qty_in Gen under each document no. is same, you can simply use a measure for calculation as below:
Measure 3 = CALCULATE(MAX('Table (2)'[Qty_ in Gen]),ALLEXCEPT('Table (2)','Table (2)'[No_]))But if there may be different values of Qty_in Gen under each document no. ,the measure needs to be modified as below:
Measure 2 = SUMX(SUMMARIZE('Table (2)','Table (2)'[No_],"total",SUMX(DISTINCT('Table (2)'[Qty_ in Gen]),'Table (2)'[Qty_ in Gen])),[total])Of course, measure 2 can also be used to calculate in situation 1 ,but measure 3 is more simpler, all depends on you.
For the related .pbix file, pls click here.
Best Regards,
Kelly