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!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
I want to add "0" to third charactor position,if the legth of the text less than 6 charactors, otherwise need to dhow the original value,I wrote the sql code as below,but this did not give the current value if the length of the text more than 6
if Text.Length[AR_ID]<6 then Text.Insert(Text.From[AR_ID],2,"0") else Text.From[AR_ID]
@LAHIRU92 Well LEN is the length function. I don't believe there is an equivalent for Insert, you would likely have to use STRING_SPLIT and then stich things back together. String Functions (Transact-SQL) - SQL Server | Microsoft Learn
Here is the IF statement definition: IF...ELSE (Transact-SQL) - SQL Server | Microsoft Learn
@LAHIRU92 Pretty sure this is Power Query M code and not SQL and pretty sure you want this:
if Text.Length([AR_ID]) < 6 then Text.Insert(Text.From([AR_ID]),2,"0") else [AR_ID]
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!