Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MINGXIN
Helper I
Helper I

PowerBI DAX distinct sum

Dear,

 

Hope you are well.

 

I have a dataset as below. I'm trying to create a formula to calculate the complete_qty corresponding to each order and then sum it up (

18.8309393

 from 2023090402R

+

14.1792

 from 2337019R

).Because Category 1 under each order should have the same complete_qty.
So overall, complete_qty should be summed up for each order.

MINGXIN_0-1697702076682.png

 

Thanks for any ideas.

 

BR

Soldier

 

 

10 REPLIES 10
lbendlin
Super User
Super User

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
If you are unsure how to do that please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

If you want to get answers faster please refer to https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Hi lbendlin,

Thanks for your reply, please find the dataset below.

Thank you so much for your attention.

lbendlin_0-1697989589319.png

like this?

 

Hi @lbendlin ,

 

Hope you are well. I tried, but there's a slight difference when there is the same qty in multiple orders, the final summary is wrong.

MINGXIN_0-1698374602467.png

 

Thanks Bro @lbendlin 

Hi @lbendlin ,

 

Thanks for your prompt action. The target table is as below.(FYI-in the report we actually only selected two orders (4 out of all), so it should be 33.01, not a summary of 4).

 

Thanks in advance.

 

Soldier

MINGXIN_0-1698022240004.png

 

That seems to match my version?

Hi @lbendlin 

 

I think I got the solution.  FYI-Solved: Grand Total ALL() with filter - Microsoft Fabric Community

 

完工数量_new =
//sumx(Values('Fact_QTY_Cost'[产成品订单号]) , calculate(distinct('Fact_QTY_Cost'[完工数量])))

Var _product = ALLSELECTED('Fact_QTY_Cost'[产成品订单号])
Var _SUTYPE = ALLSELECTED('Fact_QTY_Cost'[CATEGORY1])

Return

CALCULATE(sumx(Values('Fact_QTY_Cost'[完工数量]) , calculate(distinct('Fact_QTY_Cost'[完工数量]))),ALL('Fact_QTY_Cost'),'Fact_QTY_Cost'[产成品订单号] IN _product,'Fact_QTY_Cost'[CATEGORY1] IN _SUTYPE)
 
MINGXIN_1-1698025205098.png

 


 

May not. For new columns/metrics, the unique values should be aggregated for the currently selected orders(18.8309393+14.1792)

  • order_nocomponent_part_nocomplete_qtyCategory1
    2023090402R18192918.83094SOLVENT
    2023090402R18041918.83094SOLVENT
    2023090402R18069918.83094SOLVENT
    2337019R18019614.1792SOLVENT
    2023090402R21369618.83094PACKAGING
    2023090402R22671318.83094PACKAGING
    2337019R22181714.1792PACKAGING
    2337019R22180814.1792PACKAGING
    2337019R22180714.1792PACKAGING
    2337019R22154114.1792PACKAGING
    2337019R22148814.1792PACKAGING
    2337019R22180814.1792PACKAGING
    2337019R22905414.1792Others
    2337019R22905414.1792Others
    2023090402R18231618.83094INK
    2023090402R18577318.83094INK
    2023090402R115425218.83094FILM
    2023090402R115425218.83094FILM
    2023090402R113128818.83094FILM
    2337019R113937914.1792FILM
    2337019R113937914.1792FILM
    2337019R113844014.1792FILM
    2337019R113844014.1792FILM
    2337019R18600614.1792ADHESIVE
    2337019R18587114.1792ADHESIVE

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.