M is for Data Monkey Chapter 24

MikeDBMan

Well-known Member
Joined
Nov 10, 2010
Messages
580
I am creating a dynamic calendar table as discussed in M is for Data Monkey Chapter 24. I have the following fields, among others: Year and Month, both Whole Numbers. I wish to create a concatenated field, YYYYPP, which is the concatenation similar to this: [year] & right("0" & [month],2), so 2019, May (05) would be 201905 and 2019, December (12) would be 201912. I cannot get the formula to work in Power Query. Please help!
 

Some videos you may like

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,812
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
You could use:

Number.ToText([Year]) & Number.ToText([Month],"00")
 

MikeDBMan

Well-known Member
Joined
Nov 10, 2010
Messages
580
To insert the new column, my formula is:
Code:
= Table.AddColumn(#"Inserted Day", "YYYYPP", (each Date.Year([Date])), type number)
and I get just the year, 2019, as the result. Since this is a dynamic table, I am not sure I know how to build your formula into the line above. I've been trying for a few hours and nothing works.
 

MikeDBMan

Well-known Member
Joined
Nov 10, 2010
Messages
580
I got it. This works:
Code:
= Table.AddColumn(#"Inserted Day", "YYYYPP", each Number.ToText([Year]) & Number.ToText([Month],"00"))
Thanks for the help!
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
34,812
Office Version
365, 2019, 2016, 2010
Platform
Windows, MacOS
You could amend that to:

= Table.AddColumn(#"Inserted Day", "YYYYPP", each Date.ToText([Date], "yyyyMM"))
 

Watch MrExcel Video

Forum statistics

Threads
1,095,971
Messages
5,447,598
Members
405,458
Latest member
newbie111

This Week's Hot Topics

Top