Forum Discussion

MarcoFogale's avatar
MarcoFogale
Icon for Advocate I rankAdvocate I
4 years ago
Solved

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 exemp...
  • VahidDM's avatar
    VahidDM
    4 years ago

    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:

     

     

     

    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/