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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Einomi
Helper V
Helper V

From YYYYMM to mmm YY

Hi,

 

I have loaded my data to PQ and I have a date (DD/MM/YYYY) column. To be able to sort the date from the oldest to the newest, I have added a custom column

Date.Year([Date])*100 + Date.Month([Date])

 

this gives me a new column with the following format date YYYYMM

 

So far so good.

 

The issue is that when I load my data back to Excel I do not want this format, rather I would like this format MMM YY so that it is clearer. I have attached a pic to illustrate.

 

Any help will be appreciated

 Untitled.png

1 ACCEPTED SOLUTION
Einomi
Helper V
Helper V

I found a way to do it, here is the code

 

YYYYMM  = Table.AddColumn(#"Colonnes permutées", "YYYY_MM", each Date.Year([Date])*100 + Date.Month([Date])),
    YY = Table.AddColumn(YYYYMM, "Year", each Text.Middle(Text.From([YYYY_MM], "en-GB"), 2, 2), type text),
    mmm_YY = Table.AddColumn(YY, "MMM", each  Date.MonthName( Number.FromText( (Text.End(Text.From([YYYY_MM], "en-GB"), 2)))*29)),
    Deleted = Table.RemoveColumns(mmm_YY,{"Posted", "Name", "No.", "Amount"}),
    Format_MMM = Table.TransformColumns(Deleted, {{"MMM", each Text.Start(_, 3), type text}}),
    Final = Table.CombineColumns(Format_MMM,{"MMM", "Year"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Month")
in
    Final

 

but maybe someone has a better code to do it in less steps 🙂

 

Thanks for your time

View solution in original post

2 REPLIES 2
Einomi
Helper V
Helper V

Anyone has an idea ?

Einomi
Helper V
Helper V

I found a way to do it, here is the code

 

YYYYMM  = Table.AddColumn(#"Colonnes permutées", "YYYY_MM", each Date.Year([Date])*100 + Date.Month([Date])),
    YY = Table.AddColumn(YYYYMM, "Year", each Text.Middle(Text.From([YYYY_MM], "en-GB"), 2, 2), type text),
    mmm_YY = Table.AddColumn(YY, "MMM", each  Date.MonthName( Number.FromText( (Text.End(Text.From([YYYY_MM], "en-GB"), 2)))*29)),
    Deleted = Table.RemoveColumns(mmm_YY,{"Posted", "Name", "No.", "Amount"}),
    Format_MMM = Table.TransformColumns(Deleted, {{"MMM", each Text.Start(_, 3), type text}}),
    Final = Table.CombineColumns(Format_MMM,{"MMM", "Year"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Month")
in
    Final

 

but maybe someone has a better code to do it in less steps 🙂

 

Thanks for your time

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.