Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi,
I hope to make a new column in Query using M code like below:
To give Quarter number attribute to all row values.
Please help.
Solved! Go to Solution.
@Anonymous
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
then select the new column and fill down
Proud to be a Super User!
you can change to
=if [comments]="Q1"or [comments]="Q2" or [comments]="Q3" or [comments]="Q4" then [comments] else null
Proud to be a Super User!
@Anonymous
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
then select the new column and fill down
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
Proud to be a Super User!
Thanks!
you are welcome
Proud to be a Super User!
Thanks! accpeted.
you are welcome
Proud to be a Super User!
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 57 | |
| 43 | |
| 40 | |
| 21 | |
| 17 |
| User | Count |
|---|---|
| 183 | |
| 114 | |
| 93 | |
| 61 | |
| 45 |