Forum Discussion

ripstaur's avatar
ripstaur
Helper III
5 years ago
Solved

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.  

  • 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_] )
    

     

    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.

8 Replies

  • Icey's avatar
    Icey
    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_] )
    

     

    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.

    • ripstaur's avatar
      ripstaur
      Helper III

      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. 

  • Anonymous's avatar
    Anonymous
    Not applicable

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

     

    Thanks,

    Namish B 

     

    • ripstaur's avatar
      ripstaur
      Helper III
      1CWonderful364130812305
      1BWonderful364158721856
      1AWonderful364   
      1DEagle160   
      1FMockingbird96   
      1ERobinette83   
      1GCowpie60   
      1HGeorgeana90   
      1IDraggit149   
      1JLackett152   
      1KPickit154   
      2LSimpson269   
      2MSimpson269   
      2NRonson190   
      2OJohnson129   
      2PAlbemarle120   
      2QJohannesburg177   
      2RKimtown168   
      2SPopular132   
      2TWilherm190   
      2USampson101   
      2VFuchness111   
             
      • ripstaur's avatar
        ripstaur
        Helper III

        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

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