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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
jeongkim
Helper V
Helper V

Add column to get particular value and fill down in Query M code

Hi,

 

I hope to make a new column in Query using M code like below:

To give Quarter number attribute to all row values. 

 

jeongkim_0-1712561098582.png

 

Please help. 

2 ACCEPTED SOLUTIONS
ryan_mayu
Super User
Super User

@jeongkim 

maybe you can try this

1. add a new column

=if Text.Contains([comments],"Q1") or Text.Contains([comments],"Q2") or Text.Contains([comments],"Q3") or Text.Contains([comments],"Q4") then [comments] else null

 

11.PNG

 

then select the new column and fill down

12.PNG

13.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

you can change to 

=if [comments]="Q1"or [comments]="Q2" or [comments]="Q3" or [comments]="Q4"  then [comments] else null





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

7 REPLIES 7
ryan_mayu
Super User
Super User

@jeongkim 

maybe you can try this

1. add a new column

=if Text.Contains([comments],"Q1") or Text.Contains([comments],"Q2") or Text.Contains([comments],"Q3") or Text.Contains([comments],"Q4") then [comments] else null

 

11.PNG

 

then select the new column and fill down

12.PNG

13.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi,

 

As to Text.Contains, can we change M code to exact Q1~Q4 value not contains? 

 

you can change to 

=if [comments]="Q1"or [comments]="Q2" or [comments]="Q3" or [comments]="Q4"  then [comments] else null





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks!

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks! accpeted. 

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.