Forum Discussion
Justas4478
Post Prodigy
1 year agoCalendar date column for specific start - end date
Hi, I have calendar table and date column that is between 2023- 2025 and it automaticly changes based on earliest and latest dates in the data. I want to create another column in my calendar table t...
- 1 year ago
let
// Your existing steps here
PreviousStep = ... , // Placeholder for your existing step
// Get current year
CurrentYear = Date.Year(Date.From(DateTime.LocalNow())),
// Define the start and end dates for the custom date range
StartDate = #date(CurrentYear, 6, 1), // 1st June of the current year
EndDate = #date(CurrentYear + 1, 5, 31), // 31st May of the next year
// Add custom column for the date range check
CustomColumn = Table.AddColumn(
PreviousStep,
"CustomDateRange",
each if [Date] >= StartDate and [Date] <= EndDate then [Date] else null
)
in
CustomColumn
Kedar_Pande
Super User
1 year agolet
CurrentYear = Date.Year(Date.From(DateTime.LocalNow())),
StartDate = #date(CurrentYear, 6, 1), // 1st June of the current year
EndDate = #date(CurrentYear + 1, 5, 31), // 31st May of the next year
CustomColumn = Table.AddColumn(
PreviousStep,
"CustomDateRange",
each if [Date] >= StartDate and [Date] <= EndDate then [Date] else null
)
in
CustomColumn
Justas4478
Post Prodigy
1 year agoKedar_Pande I am getting this error when I try to add custom column in power query.
This is majory of query for calendar.
- Kedar_Pande1 year ago
Super User
let
// Your existing steps here
PreviousStep = ... , // Placeholder for your existing step
// Get current year
CurrentYear = Date.Year(Date.From(DateTime.LocalNow())),
// Define the start and end dates for the custom date range
StartDate = #date(CurrentYear, 6, 1), // 1st June of the current year
EndDate = #date(CurrentYear + 1, 5, 31), // 31st May of the next year
// Add custom column for the date range check
CustomColumn = Table.AddColumn(
PreviousStep,
"CustomDateRange",
each if [Date] >= StartDate and [Date] <= EndDate then [Date] else null
)
in
CustomColumn