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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register 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
Solution Sage
Solution Sage

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
Solution Sage
Solution Sage

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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