Forum Discussion
Hussard
7 years agoFrequent Visitor
format field
Hello, I have one column which contains version of softwares like below 3.1.7.12 3.1.7.14 2.6.5 2.6.8 27.4.12.8 and so on... My question is how can I format each numbers between ...
- 7 years ago
Hi Hussard,
Based on my test, you could refer to below steps:
Sample data:
Create 5 columns:
B = IF(PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 1)=BLANK(),BLANK(),IF(LEN(PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 1))<2,"0"&PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 1),PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 1)))C = IF(PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 2)=BLANK(),BLANK(),IF(LEN(PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 2))<2,".0"&PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 2),PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 2)))D = IF(PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 3)=BLANK(),BLANK(),IF(LEN(PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 3))<2,".0"&PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 3),"."&PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 3)))E = IF(PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 4)=BLANK(),BLANK(),IF(LEN(PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 4))<2,".0"&PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 4),"."&PATHITEM(SUBSTITUTE('Table2'[A],".", "|"), 4)))New A = Table2[B]&Table2[C]&Table2[D]&Table2[E]
Result :
You could also download the pbix file to have a view.
Regards,
Daniel He
- Anonymous7 years ago
Hi Hussard
The following way you can get your solution easily.
- Go to the Edit Query option under the ribbon pallet.
- Create a duplicate column from the existing column.
- Go to the Transform tab in Query editor and Select Split column By Delimeter within drop-down select Delimiter type as a "Custom Delimiter" and put "." in the box, then select Each occurrence of Delimeter under "Split at" option.
- Change the type of each Delimited column.
- Calculate the length of each Delimited column.
- Choose the Custom column option under the Add column option and write the below code.
- (if [FstPart Length]=1 then ("0" & [FstPart]) else [FstPart]) &
(if [FstPart Length]=0 then "" else ".") &
(if [SecPart Length]=1 then ("0" & [SecPart]) else [SecPart]) &
(if [SecPart Length]=0 then "" else ".") &
(if [ThrdPart Length]=1 then ("0" & [ThrdPart]) else [ThrdPart]) &
(if [FrthPart Length]=0 then "" else ".") &
(if [FrthPart Length]=1 then ("0" & [FrthPart]) else [FrthPart]) - Then Select "close & Apply" under the Home tab.
I have given the Sample Pbix file link below. Hope this helps you.
Anonymous
7 years agoNot applicable
Hi Hussard
The following way you can get your solution easily.
- Go to the Edit Query option under the ribbon pallet.
- Create a duplicate column from the existing column.
- Go to the Transform tab in Query editor and Select Split column By Delimeter within drop-down select Delimiter type as a "Custom Delimiter" and put "." in the box, then select Each occurrence of Delimeter under "Split at" option.
- Change the type of each Delimited column.
- Calculate the length of each Delimited column.
- Choose the Custom column option under the Add column option and write the below code.
- (if [FstPart Length]=1 then ("0" & [FstPart]) else [FstPart]) &
(if [FstPart Length]=0 then "" else ".") &
(if [SecPart Length]=1 then ("0" & [SecPart]) else [SecPart]) &
(if [SecPart Length]=0 then "" else ".") &
(if [ThrdPart Length]=1 then ("0" & [ThrdPart]) else [ThrdPart]) &
(if [FrthPart Length]=0 then "" else ".") &
(if [FrthPart Length]=1 then ("0" & [FrthPart]) else [FrthPart]) - Then Select "close & Apply" under the Home tab.
I have given the Sample Pbix file link below. Hope this helps you.
- Hussard7 years agoFrequent Visitor
Hi both,
Thanks a lot I tried both solutions and it suits me.
Regards
Sébastien