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
Paulyeo11
Impactful Individual
Impactful Individual

How to make G3 become G03 ?

Hi All

So that i can sort by G01 to G16

Paulyeo11_0-1606453204395.png

 

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @Paulyeo11 

Add a Custom Column with this line of code

 

if Text.Length([SAL_C]) = 2 then Text.Insert([SAL_C], 1, "0") else [SAL_C])

 

add-zero.png

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

5 REPLIES 5
PhilipTreacy
Super User
Super User

Hi @Paulyeo11 

Add a Custom Column with this line of code

 

if Text.Length([SAL_C]) = 2 then Text.Insert([SAL_C], 1, "0") else [SAL_C])

 

add-zero.png

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Hi Phil

Thank you for your sharing.

Paul Yeo

v-robertq-msft
Community Support
Community Support

Hi, @Paulyeo11 

According to your description, you want to insert “0” into the value which has two characters, you can try this calculated column:

SAL_C1 =

SWITCH(

    LEN([SAL_C]),

    2,LEFT([SAL_C],1)&"0"&RIGHT([SAL_C],1),

    3,[SAL_C],

BLANK())

And you can get what you want, like this:

v-robertq-msft_0-1606701592096.png

 

You can download my test pbix file here

 

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.

Hi Robert 

I will try your suggestion . Thank you very much for sharing . 
The last time I try using Amit approach , after that I get wrong target amount , may be it is due to I forget to change change the target table GROUP value label from G1 to G01

amitchandak
Super User
Super User

@Paulyeo11 , Try a new column like

if(len([sal_c]) =2 , left([sal_c],1) & "0" & right([sal_c],1) ,[sal_c])

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.