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

PQ M code: If the text in cell/row equals the text in the column header then replace it with "yes"

Hi there,

 

Hope someone would be able to help with this

 

I need to find a formula in power query m code to do the following:

 

if the text in the cell/row in the column matches the text in the column header then return "yes" otherwise return "no"

 

This is what the column could look like:

Nigel_Mayhew_0-1623066245730.png

 

Is this possible?

 

Many thanks.

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

Hi, @Anonymous 

According to your requirement, I think you can simply use the “unpiovit columns” and M language to achieve your requirement, you can go to the Power query and follow my steps:

  1. Click on the column and select “unpiovit columns”:

v-robertq-msft_0-1623224320642.png

 

  1. Create a custom column like this:

v-robertq-msft_1-1623224320647.png

v-robertq-msft_2-1623224320651.png

 

  1. Remove the [Attribute] column:

v-robertq-msft_3-1623224320654.png

 

  1. Rename the [Name] column to its original name:

v-robertq-msft_4-1623224320654.png

 

Then click on “Close and apply”, you can get what you want.

You can download my test pbix file below.

 

Thank you!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-robertq-msft
Community Support
Community Support

Hi, @Anonymous 

According to your requirement, I think you can simply use the “unpiovit columns” and M language to achieve your requirement, you can go to the Power query and follow my steps:

  1. Click on the column and select “unpiovit columns”:

v-robertq-msft_0-1623224320642.png

 

  1. Create a custom column like this:

v-robertq-msft_1-1623224320647.png

v-robertq-msft_2-1623224320651.png

 

  1. Remove the [Attribute] column:

v-robertq-msft_3-1623224320654.png

 

  1. Rename the [Name] column to its original name:

v-robertq-msft_4-1623224320654.png

 

Then click on “Close and apply”, you can get what you want.

You can download my test pbix file below.

 

Thank you!

 

Best Regards,

Community Support Team _Robert Qin

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Any suggestions please?

CNENFRNL
Community Champion
Community Champion

Sure thing, use Table.ColumnNames to retrieve header names of a table.


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Anonymous
Not applicable

What would the full formula look like? I'm struggling to put it together. 

 

Thanks.

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.