Forum Discussion

powerbiexpert22's avatar
powerbiexpert22
Impactful Individual
2 years ago
Solved

sort year month

how to sort year month column in line chart, i have yearmonth column in "YYYY-MMM" format example 2023-Jun if i try to sort YearMonth calculated column by Month( numeric column) then it only sort Ye...
  • Chakravarthy's avatar
    2 years ago

    Hi powerbiexpert22 
    Try to create a column using below code:

    Step 1:
    ===========
    YearMonth_NEW =
    VAR _MONTH = MONTH('Date'[Date])
    VAR _YEAR = YEAR('Date'[Date])
    VAR _Result = DATE(_YEAR,_MONTH,1)
    RETURN _Result
    Step 2:
    =======
    Change the Datatype as "Date"
    Change the Format as "mmmm,yyyy"
    From the top pane in Table View
     
    Step 3:
    =========
    Pull the above YearMonth_NEW column into line chart.
     
  • rajendraongole1's avatar
    2 years ago

    Hi powerbiexpert22 - Please check the image provided above, it is coming as per year and month sorting only.

     

     

    Year-Month-Sort = YEAR('Date'[Date])*12+MONTH('Date'[Date])-1
     
    Hope it works
     
    still any discrepency, please share the expected output.