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!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
I am attempting extract text from a column based on another column.
Basically if the value from column1 =1, return the first 3 characters in Column 2, if not return rthe first 2.
Example of Column1 info : 1 or 2
Column2 Info: 1234abcd
new=IF Column1="1", LEFT(table1[column2],3, LEFT(table1[column2],2
Any help is appreciated.
Solved! Go to Solution.
Hi! @therugger2000
Please use the below m code and it should work for you.
Col1 Col2 Extraction
| 1 | 123abs | 123 |
| 2 | 145grbf | 14 |
| 3 | 345 | 34 |
| 1 | 111ggg | 111 |
| 2 | 2334 | 23 |
| 1 | 2332mmm | 233 |
| 2 | 233mmm | 23 |
if [Col1] = 1 then Text.Middle ([Col2],0,3)
else
Text.Middle ([Col2],0,2)
Hi! @therugger2000
Please use the below m code and it should work for you.
Col1 Col2 Extraction
| 1 | 123abs | 123 |
| 2 | 145grbf | 14 |
| 3 | 345 | 34 |
| 1 | 111ggg | 111 |
| 2 | 2334 | 23 |
| 1 | 2332mmm | 233 |
| 2 | 233mmm | 23 |
if [Col1] = 1 then Text.Middle ([Col2],0,3)
else
Text.Middle ([Col2],0,2)
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 4 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 16 | |
| 14 | |
| 12 | |
| 7 | |
| 6 |