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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
ripstaur
Helper III
Helper III

Filtering out duplicates

So, this ought to be easy, but one of the caveats in the online training is that filters are not something a newbie like me will understand first time through. 

So here's the setup - I have some facilities. The facilities are in counties, and the counties are in larger regions. Some counties have one facility, some have two or three. I am mapping the number of cases in the area of each facility by using the county total. That's useful for the map...for example, if you look at the tooltip for any one of the three facilities in a county, you will see the county total. 

The problem comes when I try to aggregate to show the total by region...It wants to take the county total for each of the three facilities in that county and sum them...I only need one of those three added into the regional total.I don't see a way to attach a file, or I would attach an example file I built.  

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @ripstaur ,

 

Create a measure like so:

Measure =
VAR t =
    SUMMARIZE (
        'Table',
        'Table'[Region],
        'Table'[County],
        "Total_", MAX ( 'Table'[County total cases] )
    )
RETURN
    SUMX ( t, [Total_] )

country.JPG

 

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

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

8 REPLIES 8
Icey
Community Support
Community Support

Hi @ripstaur ,

 

Create a measure like so:

Measure =
VAR t =
    SUMMARIZE (
        'Table',
        'Table'[Region],
        'Table'[County],
        "Total_", MAX ( 'Table'[County total cases] )
    )
RETURN
    SUMX ( t, [Total_] )

country.JPG

 

BTW, .pbix file attached.

 

 

Best Regards,

Icey

 

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

Thanks so much. Both of these worked, but the DAX code was the way to go. I'm sorry I was unable to accept it right after you posted it, but for some reason I could not log into the Forum for a couple of weeks. 

rogletree
Helper III
Helper III

Unless I am misunderstanding, what you may be able to do is this:

Duplicate the table, and in the new table, select the column that has your duplicate entries, then in "Remove rows" select "Remove duplicates". 

Then create a one-to-many relationship with your original and duplicate table.

Then do your query where you got it to sum up the values for each county for their individual totals. May need to incorporate the RELATEDTABLE function into it.

This way you can retain your original data while also having a table that has the cumulative totals for the different counties.

Delete/change the columns for the separate tables as needed.

amitchandak
Super User
Super User

@ripstaur , Not very clear. But isinscope should help

 

https://www.kasperonbi.com/use-isinscope-to-get-the-right-hierarchy-level-in-dax/

 

example

if(isinscope ([Table[country]), calculate([measure], filter(Table,Table[region]="Region")), [measure], )

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @ripstaur, Can you try pasting the excel sample data table in as a reply. That should work

 

Thanks,

Namish B 

 

1CWonderful364130812305
1BWonderful364158721856
1AWonderful364   
1DEagle160   
1FMockingbird96   
1ERobinette83   
1GCowpie60   
1HGeorgeana90   
1IDraggit149   
1JLackett152   
1KPickit154   
2LSimpson269   
2MSimpson269   
2NRonson190   
2OJohnson129   
2PAlbemarle120   
2QJohannesburg177   
2RKimtown168   
2SPopular132   
2TWilherm190   
2USampson101   
2VFuchness111   
       

Now I see that the column headers didn't paste in...column A is Region, B is Facility, C is County D is County total cases, E contains the regional totals I want, F is region titles and G is the totals I'm getting now because of the duplicates. I have tried just specifying county totals, but since there are three entries for Wonderful County it adds them all together. 

Namish,

 

What I want to be able to do is calculate a total by region. You can see that the values  for facilities C, B and A are all the same (Because they each take on the value for “Wonderful County.” I need to be able to get the total by region without the duplicates.

 

What I’m looking for is the two totals in cells E2 and EE3; what I am currently getting is the totals in G2 and G3.

 

Thanks for your help!

 

Best regards,

 

Rip

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.