Forum Discussion

FrugalEconomist's avatar
FrugalEconomist
Helper III
10 years ago
Solved

Sorting by Fiscal Month

Dear Community,   I'm trying to report using a fiscal calendar (7/1 - 6/30) and sort it by month. However month is being sorted alphabetically by default. My month field is calculated using the for...
  • FrugalEconomist's avatar
    10 years ago

    I figured it out. Maybe it's clunky, but it solved what I was looking for.

    I created another column using the formula below. And then I sorted my [Month] variable in the modeling tab by my new column:

     

    if [Month] = "Jan" then 7
    else if [Month] = "Feb" then 8
    else if [Month] = "Mar" then 9
    else if [Month] = "Apr" then 10
    else if [Month] = "May" then 11
    else if [Month] = "Jun" then 12
    else if [Month] = "Jul" then 1
    else if [Month] = "Aug" then 2
    else if [Month] = "Sep" then 3
    else if [Month] = "Oct" then 4
    else if [Month] = "Nov" then 5
    else if [Month] = "Dec" then 6
    else 0

  • FrugalEconomist's avatar
    FrugalEconomist
    10 years ago

    Actually the above code doesn't work. Power BI sorts 1, 10, 11, 12, 2, ....

    I changed it to alphabets

     

    if [Month] = "Jan" then "G"
    else if [Month] = "Feb" then "H"
    else if [Month] = "Mar" then "I"
    else if [Month] = "Apr" then "J"
    else if [Month] = "May" then "K"
    else if [Month] = "Jun" then "L"
    else if [Month] = "Jul" then "A"
    else if [Month] = "Aug" then "B"
    else if [Month] = "Sep" then "C"
    else if [Month] = "Oct" then "D"
    else if [Month] = "Nov" then "E"
    else if [Month] = "Dec" then "F"
    else 0