MIRROR
MIRROR

Reputation: 61

Sort by Month in dropdown in power bi

I drag slicer and add Month_paid field in that and convert that one to dropdown now month looks like

Feb , aPRIL , June , Jan , Dec

i want to sort these months in dropdown how i should do this

this is the link of sample file

https://www.dropbox.com/s/sp9zfyq2sccgmmi/Claims_test_model_2.pbix?dl=0

will you please check ?

Upvotes: 1

Views: 1268

Answers (2)

StelioK
StelioK

Reputation: 1781

You can create a "sorting" calculated column by using the following DAX (or something similar):

Month Sort = 
MONTH(Claims_excel[CLM_LOSS_DT])

Once this has been created, right click on the Claims_excel[CLM_LOSS_MONTH] and click the 'Sort by' option and choose the new column.

This will produce the following results:

enter image description here

If you have actual dates in your field then create a calculated column using the following logic:

YearMonthSort = YEAR(Claims_excel[CLM_LOSS_DT])*100 + MONTH(Claims_excel[CLM_LOSS_DT])

Upvotes: 1

Deltapimol
Deltapimol

Reputation: 176

You will need another integer column in that table with numbers 1 to 12 representing the order of the Months. You can create that column in either DAX or M. When created, just select the Month column and click on 'Sort By Column' option in the Modeling tab and select the integer column which was created.This will sort the order of the months in the slicer. If the month data in the column is already in an order starting from January to December then a simple Index column (from 'Add Column' tab in Power Query editor) is enough, else a calculated column which will check the month column value for each row and put the corresponding order number in the newly calculated integer column will be required. Refer this https://radacad.com/sort-by-column-in-power-bi

Upvotes: 0

Related Questions