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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

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

Top Solution Authors