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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Heed help with filter out duplicates in DAX

Hello everyone 

I'm facing a problem. I need to calculate the aging of each record monthly based on its status. However, there is an ID containing duplicate records on Aug. The majority of the record is the same, the only difference is the supplier's information which I don't need. In this case, is there a way to remove these duplicates without influencing other months' data? 

Here is the screenshot. I'm thinking to add a filter to eliminate duplicates. 

THanks in advance for helping

Lucasw_0-1664303540324.png

 

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Anonymous 

According to your description, you want to calcuate average of the [Aging] without duplicates in dax.

Here are the steps you can refer to:

(1)This is my test data:

vyueyunzhmsft_0-1664336941019.png

(2)We can create a measure like this:

Measure = var _t= FILTER('Sheet3','Sheet3'[NC Owning Business Type Name]="Trauma and Extremities" && 'Sheet3'[NC Priority] <> 3 && 'Sheet3'[NC Project]="Nonconformance")
var _t2=SUMMARIZE(_t, [NC Pr Id],"aging" , MAX('Sheet3'[Aging]))
return 
AVERAGEX(_t2,[aging])

(3)Then we can meet your need , the result is as follows:

vyueyunzhmsft_1-1664336985994.png

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

 

Best Regards,

Aniya Zhang

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-yueyunzh-msft
Community Support
Community Support

Hi , @Anonymous 

According to your description, you want to calcuate average of the [Aging] without duplicates in dax.

Here are the steps you can refer to:

(1)This is my test data:

vyueyunzhmsft_0-1664336941019.png

(2)We can create a measure like this:

Measure = var _t= FILTER('Sheet3','Sheet3'[NC Owning Business Type Name]="Trauma and Extremities" && 'Sheet3'[NC Priority] <> 3 && 'Sheet3'[NC Project]="Nonconformance")
var _t2=SUMMARIZE(_t, [NC Pr Id],"aging" , MAX('Sheet3'[Aging]))
return 
AVERAGEX(_t2,[aging])

(3)Then we can meet your need , the result is as follows:

vyueyunzhmsft_1-1664336985994.png

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

rsbin
Super User
Super User

@Anonymous ,

Personally, I think this operation is best done using Power Query.

In Power Query, you can delete your Supplier column that you don't need.

Then use the Remove Rows to remove your duplicates

rsbin_0-1664307816460.png

Hope you can make this work for you.

Regards,

Anonymous
Not applicable

Hi, @rsbin Thanks for replying to me.

In this case, if I use the Remove duplicate button, it will remove other months' data that I really need. 

Greg_Deckler
Community Champion
Community Champion

@Anonymous Maybe:

 

Measure =
  VAR __Table = 
    SELECTCOLUMNS(
      FILTER(
        'NC Aging',
        'NC Aging'[NC Owning Business Type Name] = "Trauma and Extremities" && 
        'NC Aging'[NC Priority] <> "3" && 
        'NC Aging'[NC Project] = "Nonconformance" && 
        ([Year] <> 2022 && [Month] <> "August") 
      ),
      "__Aging",[Aging]
    )
  VAR __TableAugust = 
    DISTINCT(
      SELECTCOLUMNS(
        FILTER(
          'NC Aging',
          'NC Aging'[NC Owning Business Type Name] = "Trauma and Extremities" && 
          'NC Aging'[NC Priority] <> "3" && 
          'NC Aging'[NC Project] = "Nonconformance" && 
          ([Year] = 2022 && [Month] = "August") 
        ),
        "__NCPrId",[NC Pr Id],
        "__Aging",[Aging]
      )
    )
  VAR __FinalTable = UNION(__Table,SELECTCOLUMNS(__TableAugust,"__Aging",[__Aging]))
RETURN
  AVERAGEX(__FinalTable,[__Aging])

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors