Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MarcoFogale
Advocate I
Advocate I

Specific formatting with DAX or M

Hi,

 

I have a series of articles numbers that come from the database as an integer. The users are now used to data exported in Excel where these numbers appears with a particular format, for exemple:  1234.567.89.11

Where the number is smaller, it takes only the firsts dots - exemple: 1.22.33 or 12.234.56.78

 

I need to show them these numbers formatted this way.

How could I acheive it? I imagine I could do it with a complicated DAX formula, but I was wondering if there's another workaround. I haven't figured out yet how to make it with custom formatting string...

 

Thank in advance

 

Marco

1 ACCEPTED SOLUTION

Hi @AlexisOlson 

 

Thanks for letting me know, it makes sense now for me.

 

So @MarcoFogale  if you need DAX try this code to add a new calculated column:

New Format = 
Var _L = len('Table (2)'[article number])
Var _A = RIGHT('Table (2)'[article number],2)
Var _B = RIGHT(left('Table (2)'[article number],if(_L-2<=0,0,_L-2)),2)
Var _C = RIGHT(LEFT('Table (2)'[article number],if(_L-4<=0,0,_L-4)),3)
Var _D = RIGHT(LEFT('Table (2)'[article number],if(_L-7<=0,0,_L-7)),4)
Var _G = _D & "." & _C & "." & _B & "." & _A
Var _H = if(left(_G,1)=".",right(_G,len(_G)-1),_G)
return
_H

 

output:

VahidDM_0-1641426910377.png

 

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

View solution in original post

6 REPLIES 6
VahidDM
Super User
Super User

Hi @MarcoFogale 

 

Not sure I understood your question correctly or not (can you add a result), but if you want to remove dot from those article numbers with DAX, try this:

 

New Format = SUBSTITUTE([article number],".","")
 
output:
VahidDM_0-1641424721150.png

 

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

@VahidDM @ValtteriN, OP specified that the numbers come in integer form, which doesn't have an inherent dot formatting like that. I think they want to insert dots into a raw integer rather than remove them from a text string.

 

@MarcoFogale Please correct me if I have misunderstood.

@AlexisOlson that's correct.

For exemple:

input  (whole number) -> 2411000012312

expected output (text) -> 2411.0000.123.12

 

I was wondering if instead of a complicated DAX formula there was a way to obtain that with custom formatting strings, for example ####.####.###.## something like this...

 

Thank you 

Hi @AlexisOlson 

 

Thanks for letting me know, it makes sense now for me.

 

So @MarcoFogale  if you need DAX try this code to add a new calculated column:

New Format = 
Var _L = len('Table (2)'[article number])
Var _A = RIGHT('Table (2)'[article number],2)
Var _B = RIGHT(left('Table (2)'[article number],if(_L-2<=0,0,_L-2)),2)
Var _C = RIGHT(LEFT('Table (2)'[article number],if(_L-4<=0,0,_L-4)),3)
Var _D = RIGHT(LEFT('Table (2)'[article number],if(_L-7<=0,0,_L-7)),4)
Var _G = _D & "." & _C & "." & _B & "." & _A
Var _H = if(left(_G,1)=".",right(_G,len(_G)-1),_G)
return
_H

 

output:

VahidDM_0-1641426910377.png

 

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

AlexisOlson
Super User
Super User

If you can define the formatting rules, then it's possible in either M or DAX. Which is more convenient depends on the specific rules but M has a richer set of functions for manipulating strings and lists.

 

It's not pretty but here's an example of a custom column for one possible set of rules:

let
    T = Number.ToText([Column1]),
    L = Text.Length(T),
    Result = if L > 7 then Text.Insert(Text.Insert(Text.Insert(T, L-2, "."), L-4, "."), L-7, ".")
        else if L > 4 then Text.Insert(Text.Insert(T, L-2, "."), L-4, ".")
        else if L > 2 then Text.Insert(T, L-2, ".")
        else T
in
    Result
ValtteriN
Super User
Super User

Hi,

I believe the best way to do this is in powerquery. To do this you can do the following steps:

1. Split column with multiple comma values by delimiter. Select the right most comma as the splitpoint

2. Remove the commas from the left most column

3. Merge the two columns into one 

4. Format data as decimal number

 

Example:

ValtteriN_0-1641420826100.png

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQzNDLSMzXSMzNTitWJVjLRMzM31zM11TM3V4qNBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value = _t]),
#"Split Column by Delimiter" = Table.SplitColumn(Source, "Value", Splitter.SplitTextByEachDelimiter({"."}, QuoteStyle.Csv, true), {"Value.1", "Value.2"}),
#"Replaced Value" = Table.ReplaceValue(#"Split Column by Delimiter",".","",Replacer.ReplaceText,{"Value.1"}),
#"Merged Columns" = Table.CombineColumns(#"Replaced Value",{"Value.1", "Value.2"},Combiner.CombineTextByDelimiter(",", QuoteStyle.None),"Merged"),
#"Changed Type" = Table.TransformColumnTypes(#"Merged Columns",{{"Merged", type number}})
in
#"Changed Type"
End result:

ValtteriN_1-1641420857228.png


I hope this helps and if it does consider accepting this as a solution and giving the post a thumbs up!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.