Forum Discussion

Afirmanu's avatar
Afirmanu
Regular Visitor
2 years ago
Solved

change Format YYYYMM to MMM YY

Hello, I have a column containing YYYYMM, where I want to change to MMM YY format in DAX power BI as below   Any help will be appreciated  
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Afirmanu ,

    Thank you AlienSx very much for the solution, and I've tried other ways to help you understand the problem:

    For this problem of yours, I think the first step we have to define our data type, defining him as text type will help to help you out.

     

    FormattedDate = 
    VAR YearPart = LEFT([Posting Period], 4)
    VAR MonthPart = RIGHT([Posting Period], 2)
    VAR DateValue = DATE(VALUE(YearPart), VALUE(MonthPart), 1)
    RETURN FORMAT(DateValue, "MMM YY")

     

    This is the place where we have to sort the dates before we can realize the visual object you want.

    This is because if you don't sort them, in the matrix, they will be sorted according to the size of the letters.

     

    MonthSortOrder = 
    SWITCH(
       LEFT([Posting Period], 6),
       "202401", 1,
       "202402", 2,
       "202403", 3,
       "202404", 4,
       BLANK()
    )

     

    Regarding the problem you are having with the super user suggestion,

    I think you are not putting the super user code into the advance editor in the power query, you can try that.

    Hope it helps!

     

    Best regards,
    Community Support Team_ Tom Shen

     

    If this post helps then please consider Accept it as the solution to help the other members find it more quickly.