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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
StuartSmith
Power Participant
Power Participant

Remove Duplicate Rows based on Condition

I have a table with some almost identical rows apart from one row has a "Call Status" of "Call Received" or "Missed Call".  How can I remove any duplicate rows that have both these values and only keep the "Missed Call" row?

 

StuartSmith_1-1685531444647.png

Thanks in advance

 

EDIT: I should add, this table is a "Combine" of 2 other tables.

 

11 REPLIES 11
DOLEARY85
Super User
Super User

Hi,

 

could you not add something simple like a filter to the page/visual on call status to only show "Missed Call"?

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Unfortuantely not, when a call is recevied, a Power App will record either 1 or 2 rows, the first row records the call and if the call is answered, thats it, no additional row, but if the call is not answered, it will record a 2nd almost identical row, but with the status of "missed call".  I only want to see 1 row per call, if a call was missed, I want to see that, but if there is no "Missed Call" row, just want to see the "Call Recevied" row.  Hope that makes sense.

 

Ah okay that makes sense, try this as a measure to create a flag:

 

Measure 3 =
 
var numofrecords = CALCULATE(COUNTROWS('Table (2)'),ALLEXCEPT('Table (2)','Table (2)'[Date],'Table (2)'[Time]))
 
var missedcall = CALCULATE(Max('Table (2)'[Call Status]))
 
return
 
if(numofrecords =1,1,IF(and(numofrecords = 2,missedcall = "Call Missed"), 1,0))
 
DOLEARY85_0-1685538253195.png

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Thanks, I will accept your solution shortly as that worked great.  That said, I have found an annomily with my data and normally would only expect either 1 "Call Received" or 1 "Call Received" & 1 "Call Missed", but I have notcied one entry with 1 "Call Received" and 2 "Call Missed".  

StuartSmith_3-1685634888803.png

 

So you current solution will show both rows as they are both "Missed Call" rows.  Is there a way juts to show one row if there are more than 1 "Missed Call" rows of the same date/time?

StuartSmith_2-1685634807061.png

Thanks in advance

I presume its a "Max" function, but cant figure out where to add it 🙂

I suspect you're right that it will include MAX or possibly RANKX, i haven't got time to look at it today but i'll see what i can do tomorrow. if you want to include both the missed calls for now change the part of the measure  "= 2" to ">= 2" otherwise as there are 3 rows it will mark them all as 0

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

I think the issue is going to be that both rows are identical, do you have a unique row number in the data anywhere? or could you add an index row in Power Query?

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

There is an ID coulmn pulled from the SP List, although can also add an index column from within BI if that helps.

Sorry about the delay, if you add an Index column in Power Query then try this:

 

Measure 3 =
 
var numofrecords = CALCULATE(COUNTROWS('Table (2)'),ALLEXCEPT('Table (2)','Table (2)'[Date],'Table (2)'[Time]))
 
var missedcall = CALCULATE(Max('Table (2)'[Call Status]))
 
return
 
if(numofrecords =1,1,IF(and(numofrecords = 2,missedcall = "Call Missed"), 1,IF(AND(numofrecords>=3,missedcall = "Call Missed" && MAX('Table (2)'[Index])),1,0)))
 
If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Thanks for getting back to me and you are helping me out, so happy to wait 🙂  I tried your code and the Max function doesnt seem to be picking up the "Max" index value.  I tried MaxA, Min, and none seem to work.  It seems to be marking them all as "1".

 

StuartSmith_0-1686044938869.png

 

 

That's odd, it seems to work with my tests. Are you able to share your PBIX file?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.