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
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], )

 

NamishB
Post Prodigy
Post Prodigy

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
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.