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
PowerBINoob24
Resolver I
Resolver I

Keep Duplicates in Summarized Table

I created a table using the Summarize function and I would like to keep the duplicates and remove everything else; however, when I go into power query I only see the actual data table that have been imported into the desktop.  Is there a way to keep duplicates and remove everything else in a summarized table?  All of search return solutions for deleting dupicates, not keeping duplicates.

 

Thanks in advance.

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

Hi @PowerBINoob24 ,

 

Please try this:

Table =
VAR _table =
    SUMMARIZE ( 'Table1', 'Table1'[E-Mail], 'Table1'[Value] )
VAR _filter_table =
    FILTER (
        'Table1',
        CALCULATE (
            COUNT ( 'Table1'[E-Mail] ),
            FILTER ( ALL ( 'Table1' ), 'Table1'[E-Mail] = EARLIER ( 'Table1'[E-Mail] ) )
        ) > 1
    )
RETURN
    _filter_table

Table1:

vcgaomsft_0-1674544582766.png

Table:

vcgaomsft_1-1674544620884.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

7 REPLIES 7
v-cgao-msft
Community Support
Community Support

Hi @PowerBINoob24 ,

 

Please try this:

Table =
VAR _table =
    SUMMARIZE ( 'Table1', 'Table1'[E-Mail], 'Table1'[Value] )
VAR _filter_table =
    FILTER (
        'Table1',
        CALCULATE (
            COUNT ( 'Table1'[E-Mail] ),
            FILTER ( ALL ( 'Table1' ), 'Table1'[E-Mail] = EARLIER ( 'Table1'[E-Mail] ) )
        ) > 1
    )
RETURN
    _filter_table

Table1:

vcgaomsft_0-1674544582766.png

Table:

vcgaomsft_1-1674544620884.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

@v-cgao-msft Hello, why VAR _table is created but not used?

Ashish_Mathur
Super User
Super User

Hi,

Share some data (in a format the can be pasted in an MS Excel file) and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

I can't sahre the data as it's confidential, but the expected result is to essentially retain all rows that contain email addresses that are repeated and remove any that are only listed once, i.e if the email powerbinoob24@nowheredotcom shows up 2,3,4 or more times then keep all those rows.  If it only shows up once don't show the row.

Hi,

This M code works.  It will reduce the rows in the table from 3 to 2 (see 2 images below)

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"E-mail", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"E-mail"}, {{"GroupTables", each _, type table [#"E-mail"=nullable text]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "CountRows", each Table.RowCount([GroupTables])),
    #"Expanded GroupTables" = Table.ExpandTableColumn(#"Added Custom", "GroupTables", {"E-mail"}, {"E-mail.1"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded GroupTables", each [CountRows] > 1),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"E-mail.1", "CountRows"})
in
    #"Removed Columns"

Untitled.pngUntitled1.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks for this; however, I've never used M code before.  I assume it's used in the same way as DAX.  I'm not clear though...your code has "source = excel.currentworkbook"  I need to use this in a power BI dashboard, not excel.

You are welcome.  The name of the Table is Data.  Click on Transform data and paste the code there.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.