Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
I imported this data from Excel to powerbi. Now I need to change column 3 :- (Month name to month and year).
For example From April to April 2019. My column 3 need to read as April 2019, May 2019.... till Oct 2022
Solved! Go to Solution.
Hi @arjun_para
Assuming that Jan to Mar are from the next calendar year, try this M code.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwtNQ1MjAyUNJRCjQEEo4FRZk5SrE60UpADhD5JlYi8bxK81JRuDnIso6l6Ui84NSCEhg30AgkhpDzTy5B4vnllyHxXFKT4dqMUbV5JeYh8dxSk1AcWgTmgTwD8pHhcPKRIchHRgPgo1gA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
#"Replaced Value" = Table.ReplaceValue(Source,"",null,Replacer.ReplaceValue,{"Column1", "Column2"}),
#"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}}),
#"Filled Down" = Table.FillDown(#"Changed Type",{"Column1", "Column2"}),
#"Filtered Rows" = Table.SelectRows(#"Filled Down", each [Column3] <> null and [Column3] <> ""),
#"Added Custom" = Table.AddColumn(#"Filtered Rows", "Parsed Date", each let
// Extracts the first 4 characters from Column1, representing the starting year
yr1 = Text.Start([Column1],4),
// Extracts the last 4 characters from Column1, representing the ending year
yr2 = Text.End([Column1],4),
// Stores the month name from Column3
_month = [Column3],
// Determines which year to use based on the month
// If the month is Jan, Feb, or Mar, use the second year (yr2)
// Otherwise, use the first year (yr1)
year_to_use =
if _month = "Jan" or _month = "Feb" or _month = "Mar"
then yr2
else yr1,
// Concatenates the first three letters of the month with the selected year
mo_yr = Text.Start(_month,3) & " " & year_to_use,
// Converts the concatenated text into a date format
parsed_date = Date.From(mo_yr)
in
parsed_date),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Month and Year", each Date.ToText([Parsed Date], "MMMM yyyy")),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom1",{{"Parsed Date", type date}, {"Month and Year", type text}})
in
#"Changed Type1"
Create a blank query, delete everything inside and paste this code to see how the data is being transformed. The result should be as below.
Hi @arjun_para
Assuming that Jan to Mar are from the next calendar year, try this M code.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwtNQ1MjAyUNJRCjQEEo4FRZk5SrE60UpADhD5JlYi8bxK81JRuDnIso6l6Ui84NSCEhg30AgkhpDzTy5B4vnllyHxXFKT4dqMUbV5JeYh8dxSk1AcWgTmgTwD8pHhcPKRIchHRgPgo1gA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t, Column3 = _t]),
#"Replaced Value" = Table.ReplaceValue(Source,"",null,Replacer.ReplaceValue,{"Column1", "Column2"}),
#"Changed Type" = Table.TransformColumnTypes(#"Replaced Value",{{"Column1", type text}, {"Column2", type text}, {"Column3", type text}}),
#"Filled Down" = Table.FillDown(#"Changed Type",{"Column1", "Column2"}),
#"Filtered Rows" = Table.SelectRows(#"Filled Down", each [Column3] <> null and [Column3] <> ""),
#"Added Custom" = Table.AddColumn(#"Filtered Rows", "Parsed Date", each let
// Extracts the first 4 characters from Column1, representing the starting year
yr1 = Text.Start([Column1],4),
// Extracts the last 4 characters from Column1, representing the ending year
yr2 = Text.End([Column1],4),
// Stores the month name from Column3
_month = [Column3],
// Determines which year to use based on the month
// If the month is Jan, Feb, or Mar, use the second year (yr2)
// Otherwise, use the first year (yr1)
year_to_use =
if _month = "Jan" or _month = "Feb" or _month = "Mar"
then yr2
else yr1,
// Concatenates the first three letters of the month with the selected year
mo_yr = Text.Start(_month,3) & " " & year_to_use,
// Converts the concatenated text into a date format
parsed_date = Date.From(mo_yr)
in
parsed_date),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Month and Year", each Date.ToText([Parsed Date], "MMMM yyyy")),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom1",{{"Parsed Date", type date}, {"Month and Year", type text}})
in
#"Changed Type1"
Create a blank query, delete everything inside and paste this code to see how the data is being transformed. The result should be as below.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.