Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Lunge_PTP
Regular Visitor

show date as yyyy-mm and sorted by month

I have created a new column with this: 

Indbetaling_År_MD = YEAR([Indbetalingsdato]) & "-" & MONTH([Indbetalingsdato])
when data is presented in a table I get this:
2017-1
2017-10
2017-11
2017-12
2017-2
I would like it, to be sorted/shown this way: 2017-01, 2017-02, ..... 2017-11, 2017-12
When I run the data through Excel and do the same task, and then import the data as Excel I get the date as: 2017 january, 2017 february which is fine with me.
 How do I solve this problem?
1 ACCEPTED SOLUTION
Payeras_BI
Super User
Super User

Hi @Lunge_PTP ,
You can also use FORMAT for this purpose:

FORMAT('Calendar'[Indbetalingsdato],"YYYY-MM")

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

View solution in original post

4 REPLIES 4
Payeras_BI
Super User
Super User

Hi @Lunge_PTP ,
You can also use FORMAT for this purpose:

FORMAT('Calendar'[Indbetalingsdato],"YYYY-MM")

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain
Anonymous
Not applicable

Generally I create the Calendar using Power Query. Here you can add a column like this:

 

Column Name: "YearMonthNo"

Expression

= Text.Combine(
{Date.ToText([Indbetalingsdato], "yyyy"), "-", Date.ToText([Indbetalingsdato], "MM")}))

Mohammad_Refaei
Solution Specialist
Solution Specialist

Go to data view, select your new column, in column tools choose sort by (Date).

 

m_refaei_0-1627047027657.png

 

Samarth_18
Community Champion
Community Champion

Hi @Lunge_PTP 

 

Instead you can duplicate your date column and change its date format directly from ribbon as shown in below screenshot. Since the way you following to create a column actually its converting that column as text and its causing issue while sorting.

 

Samarth_18_0-1627046592422.png

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.