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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
shafeeqansar
Regular Visitor

Create New Measure by filtering distinct id's

Hi , 

I want to create a new measure where i need to do SUM(AMOUNT) by filtering DISTINCT ID's. Can anyone help me with the DAX Expression to create new Measure in Power BI Desktop.

I have tried using the below expression but it is throwing error.

NEW_MEASURE =
CALCULATE (SUM(TEST[AMOUNT]), FILTER('TEST'[ID] IN SELECTCOLUMNS(DISTINCT('TEST'[ID],"Distinct_id"))

 

Error : Too many arguments were passed to the Distinct Function.

 

Note : The table contains duplicate ID's so need to filter data first then use SUM(AMOUNT). Ignore the TYPE column for now as we are only interested in ID & AMOUNT columns.

 

Sample Data : 

 

Table Name = TEST

 

ID         TYPE         AMOUNT

111        AA              10

111        BB               10

111        CC              10

222        BB               20

222        AB              20

222        CB              20

222        BA             20

333        ZZ              30

333        ZX              30

444        MN             40

444        MG             40

444        MX             40

 

In the above example the ID's are duplicated . So we need to first filter and get all the distinct ID's then  SUM(AMOUNT).

New Measure = SUM(AMOUNT) based on  Distinct ID's in the table

 

New Measure = (10 + 20 + 30 + 40 ) = 100 should be the final output .

 

Any kind of help is highly appreciated.

 

Thanks.

SA

 

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @shafeeqansar,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
v-shex-msft
Community Support
Community Support

Hi @shafeeqansar,

I'd like to suggest you take a look at the following blog about measure total to know how to use measure expression calculate with multiple aggregations:

Measure Totals, The Final Word 
Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
MFelix
Super User
Super User

Hi @shafeeqansar ,

 

Try the following measure:

Total Amount = 
sumx (SUMMARIZECOLUMNS('Table'[ID],'Table'[Amount]), 'Table'[Amount])

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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