Reputation: 127
Hi I'm trying to order a table in BI by monthNumber, but now I have same months in differents year, and PowerBI doesn't care about that. I have:
- Jan-20
- Feb-19
- Feb-20
- Mar-19
- Mar-20
- Apr-19
- May-19
- Jun-19
- Jul-19
- Aug-19
- Sep-19
- Oct-19
- Nov-19
- Dec-19
And I want:
- Feb-19
- Mar-19
- Apr-19
- May-19
- Jun-19
- Jul-19
- Aug-19
- Sep-19
- Oct-19
- Nov-19
- Dec-19
- Jan-20
- Feb-20
- Mar-20
NOTE: Each month I will add a new month (The actual current month e.g. Now Aug-20) and this should still work properly
Upvotes: 1
Views: 78
Reputation: 16908
Let your table name is "order_by_month" and the column name is "month_year". Now just follow this following steps to order data as per your requirement.
Step-1: In Power Query, create a custom column as below image-
We are generating this column with the First date of each month so that we can order our original data later based on the Date value. The generated value in the new column will look like below-
Step-2: Change the above red marked column's data type as Date.
Step-3: Get back to report by clicking the "Close & Apply" Button.
Step-4: In the report, go to Table view and select your original column "month_year" and order this column by newly created column "date_formatted_value" as shown in the beloe image.
Now the final output will be sorted as below as you wants-
Upvotes: 3