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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
preethi
New Member

How to remove duplicate records

I connected to Cassandra DB and get the Data using API call, able to create the table. However, wanted to know how to remove the duplicate records.

 

DateTimeMessageIDGatewayIDNameSensorTypeValueIsBreached
2017-02-08T17:06:01+01:0045345243234234Data1Light0FALSE
2017-02-08T17:06:01+01:0045345243234234Data1Humidity45FALSE
2017-02-08T17:06:01+01:0045345243234234Data1Temperature24FALSE
2017-02-08T17:06:01+01:0045345243234234Data1Battery2556FALSE
2017-02-08T17:06:01+01:0045345243234234Data1Shock1000FALSE
2017-02-08T17:06:01+01:0045345243234234Data1Tilt180TRUE

 

Expected: 

 

 

DateTimeMessageIDGatewayIDNameLightIsBreachedHumidityIsBreachedTemperatureIsBreachedBatteryIsBreachedShockIsBreachedTiltIsBreached
2017-02-08T17:06:01+01:00ca6acf53-c68d-4714-930d-03ee5e9f4e2117007D8063SensorBreach0FALSE45FALSE24FALSE2256FALSE1000FALSE180FALSE
                

 

 

 

 

4 REPLIES 4
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @preethi,

Based on the article @ImkeF posted, I try to reproduce your scenario using Unpivot columns and Merge function in Edit Query catelog.

This is my Power Query Statement.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("rZG9CsIwEIDfJast3OWnLd0UFYdONk6lQ9DQBi1KuA6+vZc+ggQCX4aPj+NuGIQErEuQJTQW6xaqFnAH2AKIQmijtGFKraTS/Ph/dOSQ2YVpJmbyzvuuP4mx+L92WZfwCPTdtCxF65ePj47W6DcjS/TgiHxMU0pjqizJfn7fn0wEyLNKG17pLtgk0V5vXBt/", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [DateTime = _t, MessageID = _t, GatewayID = _t, Name = _t, SensorType = _t, Value = _t, IsBreached = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"DateTime", type datetimezone}, {"MessageID", Int64.Type}, {"GatewayID", Int64.Type}, {"Name", type text}, {"SensorType", type text}, {"Value", Int64.Type}, {"IsBreached", type logical}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"DateTime", "MessageID", "GatewayID", "Name", "SensorType", "Value"}, "Attribute", "Value.1"),
    #"Merged Columns" = Table.CombineColumns(#"Unpivoted Columns",{"SensorType", "Attribute"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"),
    #"Reordered Columns" = Table.ReorderColumns(#"Merged Columns",{"DateTime", "MessageID", "GatewayID", "Name", "Merged", "Value.1", "Value"})
in
    #"Reordered Columns"


And get the followng result.

Capture1.PNG

We're unable to transfer the part of column to Rows in Power BI desktop. All the columns will be transfered when I click "Transpose". Thanks for understanding.

Best Regards,
Angelia


Phil_Seamark
Microsoft Employee
Microsoft Employee

In the Query Editor, select the columns you want to remove duplicates and this should work for  you.

 

remove dupliates.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

The data is avaliable as Name value pair in the columns, please check the data again for more clarity.

ImkeF
Community Champion
Community Champion

In order to achieve what you've showed you don't have to remove duplicates, but to pivot your data on a pair of columns. I've described the technique here:

http://www.thebiccountant.com/2015/08/12/how-to-pivot-multiple-measurescolumns-in-power-query/

 

Pls let me know if you need help implementing this.

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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