Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have a column that looks like (A) and I want it to look like (B). How can I extract only the month and the year of each item in column A so that it can be a custom column like B?
A:
01/01/2020 12:00:00 AM
01/02/2020 12:00:00 AM
01/03/2020 12:00:00 AM
01/04/2020 12:00:00 AM
B:
01/2020
01/2020
01/2020
01/2020
Solved! Go to Solution.
Hi @Anonymous ,
You could try the following codes, it will return text type values.
= Table.AddColumn(#"Changed Type", "Custom", each
(if
Date.Month([Column1])<10
then
"0" & Number.ToText(Date.Month([Column1]))
else
Number.ToText(Date.Month([Column1])))
&"/"&
Number.ToText(Date.Year([Column1])))
Hi @Anonymous ,
You could try the following codes, it will return text type values.
= Table.AddColumn(#"Changed Type", "Custom", each
(if
Date.Month([Column1])<10
then
"0" & Number.ToText(Date.Month([Column1]))
else
Number.ToText(Date.Month([Column1])))
&"/"&
Number.ToText(Date.Year([Column1])))
Hi @Anonymous
In Power Query you can either:
a) Create a custom column with the code
= [Column A]
and then convert the type to Date (instead of the DateTime it now is
b) Create a custom column with the code
= Date.StartOfDay( [Column A] )
Please mark the question solved when done and consider giving kudos if posts are helpful.
Contact me privately for support with any larger-scale BI needs, tutoring, etc.
Cheers
Check out the July 2025 Power BI update to learn about new features.