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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
fep
Helper I
Helper I

Modify m code date table

How do I modify the Enterprise DNA code date table to add a column like this. Here is the link for det m code

 

https://forum.enterprisedna.co/t/extended-date-table-power-query-m-function/6390

 

InsertTermin = Table.AddColumn(InsertMonth, "Termin", each if [Month] >= 1 and [Month] <= 7 then "Vår" else if [Month] > 7 and [Month] <= 12 then "Høst") else null

1 ACCEPTED SOLUTION
sevenhills
Super User
Super User

Say, if your original code is like this

 

InsertMonth = Table.AddColumn(InsertCompletedQuarter, "Month", each Date.Month([Date]), type number),
      InsertStartOfMonth = Table.AddColumn(InsertMonth, "Start of Month", each Date.StartOfMonth([Date]), type date),
      

 

 

You change it as

 

      InsertMonth = Table.AddColumn(InsertCompletedQuarter, "Month", each Date.Month([Date]), type number),
      InsertTermin = Table.AddColumn(InsertMonth, "Termin", each if [Month] >= 1 and [Month] <= 7 then "Var" else if [Month] > 7 and [Month] <= 12 then "Host" else null, type text),
      InsertStartOfMonth = Table.AddColumn(InsertTermin, "Start of Month", each Date.StartOfMonth([Date]), type date),
      

 

sevenhills_0-1697649070987.png

 

Additionally, This link is very popular and a video is posted for explanation on the same link.

View solution in original post

1 REPLY 1
sevenhills
Super User
Super User

Say, if your original code is like this

 

InsertMonth = Table.AddColumn(InsertCompletedQuarter, "Month", each Date.Month([Date]), type number),
      InsertStartOfMonth = Table.AddColumn(InsertMonth, "Start of Month", each Date.StartOfMonth([Date]), type date),
      

 

 

You change it as

 

      InsertMonth = Table.AddColumn(InsertCompletedQuarter, "Month", each Date.Month([Date]), type number),
      InsertTermin = Table.AddColumn(InsertMonth, "Termin", each if [Month] >= 1 and [Month] <= 7 then "Var" else if [Month] > 7 and [Month] <= 12 then "Host" else null, type text),
      InsertStartOfMonth = Table.AddColumn(InsertTermin, "Start of Month", each Date.StartOfMonth([Date]), type date),
      

 

sevenhills_0-1697649070987.png

 

Additionally, This link is very popular and a video is posted for explanation on the same link.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.