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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Hell-1931
Helper II
Helper II

Summarizing numbers over Distinct values in DAX Power BI

Hi All,

I am having trouble receiving correct result when trying to sum numbers over Distinct values (in DAX Power BI)

I have the following table - Tbl_Eposode:

Data.PNG

 

I expect to have total numbers of [Episode] = 12

But I keep having SUM of [Episode] = 36 (my code just summarizes all Episode values instead only summarizing unique Episodes (by EpisodeID, ProgramID))

 

This is my code:

 

# Pre Homeless Days = CALCULATE(SUM('Tbl_Episode'[Episode]), ALLEXCEPT('Tbl_Episode','Tbl_Episode'[EpisodeID],'Tbl_Episode'[ProgramID],'Tbl_Episode'[ClientID]))

 

 

 

PLEASE HELP!

 

 

 

1 ACCEPTED SOLUTION

Hi @Hell-1931 ,

Is there any other field exist in your fact table except the fields in below screenshot? It can get the correct result: 12 when I use the same formula as suggested by @Hariharan_R ....

yingyinr_0-1661307196744.png

In addition, you can refer the following links to get it.

DAX method:

Calculate the sum of Duplicate values from a Table

SizeWithoutDuplicates =
SUMX (
    DISTINCT ( unstructured[Hash] ),
    CALCULATE(DISTINCT(unstructured[Size]))
)

Sum distinct values for first occurance in Power BI

Total = SUMX(DISTINCT(Data[Name]), FIRSTNONBLANK(Data[Value], 0))

yingyinr_2-1661308190102.png

Power Query method:

How to combine duplicate rows and sum its values

yingyinr_1-1661308128229.png

 

If the above one can't help you get the desired result, please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examplesIt is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-yiruan-msft
Community Support
Community Support

Hi  @Hell-1931 ,

Whether your problem has been resolved? If yes, could you please mark the helpful post as Answered? It will help the others in the community find the solution easily if they face the same problem as yours. Thank you.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hariharan_R
Solution Sage
Solution Sage

Hi @Hell-1931 

Tryt the below measure.

 

Measure = 
var _distinct = DISTINCT(VALUES('Table'))
RETURN
SUMX(_distinct, 'Table'[Episode])

 

Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


My Blog :: YouTube Channel :: My Linkedin


Unfortunately,  it keeps resulting in 36 not 12

Hi @Hell-1931 ,

Is there any other field exist in your fact table except the fields in below screenshot? It can get the correct result: 12 when I use the same formula as suggested by @Hariharan_R ....

yingyinr_0-1661307196744.png

In addition, you can refer the following links to get it.

DAX method:

Calculate the sum of Duplicate values from a Table

SizeWithoutDuplicates =
SUMX (
    DISTINCT ( unstructured[Hash] ),
    CALCULATE(DISTINCT(unstructured[Size]))
)

Sum distinct values for first occurance in Power BI

Total = SUMX(DISTINCT(Data[Name]), FIRSTNONBLANK(Data[Value], 0))

yingyinr_2-1661308190102.png

Power Query method:

How to combine duplicate rows and sum its values

yingyinr_1-1661308128229.png

 

If the above one can't help you get the desired result, please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examplesIt is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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