Forum Discussion

nok's avatar
nok
Icon for Advocate II rankAdvocate II
1 year ago
Solved

Remove duplicate rows based on occurrence of a specific string in Power Query

I have a table that follows this structure:

IDImageText
1NameFarm.pdf
1Reversed_Image_[1].pdf
2Reversed_Image_[9].jpg
3Reversed_Image_[3].jpg
3vintage_paint.jpg
4noble.pdf

 

I want to create a function, in Power Query, that checks if an ID appears more than once. If so, the BI should delete the row where the "ImageText" column contains the string "Reversed_Image".

If the ID does not repeat, the BI should not delete anything. This function should be executed only when a certain ID repeats.

The final result would be something like this:

IDImageText
1NameFarm.pdf
2Reversed_Image_[9].jpg
3vintage_paint.jpg
4noble.pdf


How can I do this?

7 Replies

    • nok's avatar
      nok
      Icon for Advocate II rankAdvocate II

      Hello, parry2k . Thanks for the quick response!
      I downloaded your file and tried to use it in my code, but I'm getting an error in the #"Get ImageText" step, saying that the name 'fnGetImageText' was not recognized.
      Do I need to change something in this part of 'fnGetImageText' for it to work on my dashboard?

  • nok why for ID 2, both the rows are not deleted becuase both contains "Reversed_Image"

  • nok got it, ID 2 has only one record. Hang tight for the solution

  • nok there is another function in PQ which you need to copy in your pbix file.

    • nok's avatar
      nok
      Icon for Advocate II rankAdvocate II

      Thanks for the response, I had managed to find it here 🙂
      Just one last question... in my original table, I have more columns than "ID" and "ImageText". How do I make the last step bring all the other columns as well, and not just "ID" and "ImageText"?

  • nok before the last step (removal of all column), click expand arrow on the all column, it will list all the columns, just select the columns you need and then remove the all column.