Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
8 | |
6 | |
6 | |
6 | |
5 |