'Sort column circular dependency in Power BI

I have to sort month name from January to December in Power BI Desktop. Power BI sorts the column according to the alphabetical order.

Here is my dataset:
Data-set

When I am using sort by column by month number, I am getting an error of circular dependence:

Error message

There is no date table in my dataset. I have calculated month number as calculated column.

How can I get rid of this circular dependency? This is the desired result:
Final result



Solution 1:[1]

Go to the power query editor and duplicate the Month column and then create a new step using the following code:

= let
   Source = #"Previous Step Name",
   Substitutions = [
   #"January" = "1",
   #"February" = "2",
   #"March" = "3",
   #"April" = "4",
   #"May" = "5",
   #"June" = "6",
   #"July" = "7",
   #"August" = "8",
   #"September" = "9",
   #"October" = "10",
   #"November" = "11",
   #"December" = "12"],
   Substituted = Table.TransformColumns(Source, {{"Duplicate Month Column", each Record.FieldOrDefault(Substitutions, _, _)}})
in
   Substituted

Remember to replace the Previous Step Name and Duplicate Month Column for the corresponding name.

Finally go to the Data tab and select your month column and select the Sort by Column option and sort it using the new created column.

Solution 2:[2]

The sort column doesn't work if created like this:

sort order circular dependency power bi 1

It works when it's created like this:

sort order circular dependency power bi 2

Solution 3:[3]

Go to Data tab in power bi, Select the column that you need to select and click on the Sort by Column and select the column need to be used for sorting (see below pic, In this case month name is being sorted based on the Month of the Year column)

enter image description here

Solution 4:[4]

The fastest solution is to create a column in the same table with an IF or SWITCH statement for each month and sort your MonthName by your MonthNumber.

Code below:

Month_Num = SWITCH(TRUE,
[Month] = "Jan",
1,
[Month] = "Feb",
2,
[Month] = "Mar",
3,
[Month] = "Apr",
4,
[Month] = "May",
5,
[Month] = "Jun",
6,
[Month] = "Jul",
7,
[Month] = "Aug",
8,
[Month] = "Sep",
9,
[Month] = "Oct",
10,
[Month] = "Nov",
11,
[Month] = "Dec",
12)

Solution 5:[5]

Create a support table for month name and month number . That support table will be static and it has Month name and month number(better create in excel and copy it into power bi instead creating a calculated column) In my case my it will be based on fiscal year.

[Image shows the data created in excel

Then Sort that support table month name with month number. Join the month name of support table with month name of your main table . Drag the month column from support table instead of main table into your Graph. Thats it. If its still not sorted then click on graph and sort it based on month name.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Agustin Palacios
Solution 2 ZygD
Solution 3 balaji
Solution 4 Angelo Canepa
Solution 5 ZygD