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
Anonymous
Not applicable

Remove specific columns from a multi-column table based on another single-column table

Hi,

 

I need to remove specific unwanted columns from the below DataExtract Table after unpivoting it's Attribute columns to reduce its huge size. The problem is that everytime a new DataExtract file will be imported and it may have different Attribute column names everytime.

 

DataExtract Table: (pivoted)

 

ItemID    Attr1                       Attr2                        Attr3                      Attr4

10001      natural and soft     put in auto mode      so natural!               get auto; get auto mode

10002      bus at stop             natural icecream       boy is ingenius        more power

10003      let me out!             promote goodwill     simple simon           auto model

10004      matching color      natural color              natural essence       figure it!

10005      god will                  meet at bus stop       similar cases            rosetta stone

10006      mud ringworm       helper columns         rainbow color          geneva convention

10007      masked man          tenor voice                silica gel                   natural smell

10008      microcosm             guns of navarone      bloated cell              enigmatic man

10009      cellular sky             natural color              color coated            ingenius of him!

10010      ingenius body        maker chambers       old story                  minor changes

 

 

DataExtract Table: (unpivoted)

 

ItemID    AttributeName    AttributeValue

10001Attr1natural and soft
10001Attr2put in auto mode
10001Attr3so natural!
10001Attr4get auto; get auto mode
10002Attr1bus at stop
10002Attr2natural icecream
10002Attr3boy is ingenius
10002Attr4more power
10003Attr1let me out!
10003Attr2promote goodwill
10003Attr3simple simon
10003Attr4auto model
10004Attr1matching color
10004Attr2natural color
10004Attr3natural essence
10004Attr4figure it!
10005Attr1god will
10005Attr2meet at bus stop
10005Attr3similar cases
10005Attr4rosetta stone
10006Attr1mud ringworm
10006Attr2helper columns
10006Attr3rainbow color
10006Attr4geneva convention
10007Attr1masked man
10007Attr2tenor voice
10007Attr13silica gel
10007Attr4natural smell
10008Attr1microcosm
10008Attr2guns of navarone
10008Attr3bloated cell
10008Attr4enigmatic man
10009Attr11cellular sky
10009Attr2natural color
10009Attr3color coated
10009Attr4ingenius of him!
10010Attr1ingenius body
10010Attr12maker chambers
10010Attr3old story
10010Attr4minor changes

 

I have created an Unwanted Table of Attribute columns that i will manually add unwanted columns in it and then load it to Power Query. I need to use it on the DataExtract Table to remove or filter those unwanted Attribute columns.

 

Unwanted Table:

 

Attribute

Attr11

Attr12

Attr13

 

How can this be done in PowerQuery for Excel?

 

1 ACCEPTED SOLUTION
edhans
Super User
Super User

In Power Query, do this:

  • Merge your main data table with your UNWANTED data. In the merge type, choose Left Anti. It will only keep rows that do not exist in the unwanted data.
  • Then delete the column where the merge occurs in the next step. No need to expand anything as they are all nulls.

Is that what you want? If not, give a clearer example of the expected outcome.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

2 REPLIES 2
edhans
Super User
Super User

In Power Query, do this:

  • Merge your main data table with your UNWANTED data. In the merge type, choose Left Anti. It will only keep rows that do not exist in the unwanted data.
  • Then delete the column where the merge occurs in the next step. No need to expand anything as they are all nulls.

Is that what you want? If not, give a clearer example of the expected outcome.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Greg_Deckler
Super User
Super User

You could do this easily in DAX using EXCEPT.

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.