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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Justas4478
Post Prodigy
Post Prodigy

Calendar 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 that only starts from 01/06 of this year (it would be 2024) and end on 31/05 next year in this case it would be 2025.
I havent done this before and I dont know if it is possible.
I hope that there is some solution that would avoid the need to specify specific year in the solution.


1 ACCEPTED SOLUTION

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
If this helped, please give Kudos or mark it as a Solution .
Best regards,
Kedar
Connect on LinkedIn

View solution in original post

7 REPLIES 7
Bibiano_Geraldo
Resident Rockstar
Resident Rockstar

Hi,
Create a new column in your calendar table and past the following DAX.
Note: Make sure to change column and table name to your owns.
If this answer satisfy your question, please mark it as soluction.

Column =
VAR CurrentYear = YEAR(TODAY())
VAR vStart = DATE(CurrentYear , 6 , 1)
VAR vEnd = DATE(CurrentYear + 1 , 5 , 31)
RETURN
IF(
    'Calendar'[Date] >= vStart && 'Calendar'[Date] <= vEnd,
    'Calendar'[Date] ,
    BLANK()
)
I hope this helps! 
If you found this answer helpful:
✔️ Mark it as the solution to help others find it faster.
 Give it a like to show your appreciation!

Thank you for contributing to our amazing Power BI community! 
Kedar_Pande
Community Champion
Community Champion

@Justas4478 

You can create a custom column in your calendar table

CustomDateRange =
VAR StartDate = DATE(YEAR(TODAY()), 6, 1)
VAR EndDate = DATE(YEAR(TODAY()) + 1, 5, 31)
RETURN
IF(
'Calendar'[Date] >= StartDate && 'Calendar'[Date] <= EndDate,
'Calendar'[Date],
BLANK()
)

This logic dynamically sets the range from June 1st of the current year to May 31st of the next year. The column will only return dates within that range and leave others as blank.

 

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

If this helped, please give Kudos or mark it as a Solution .
Best regards,
Kedar
Connect on LinkedIn

@Kedar_Pande Hi your solution works, but is it possible to do this in power query?

@Justas4478 

let
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

If this helped, please give Kudos or mark it as a Solution .
Best regards,
Kedar
Connect on LinkedIn

@Kedar_Pande I am getting this error when I try to add custom column in power query.

Justas4478_0-1729077195993.png

This is majory of query for calendar.

Justas4478_1-1729077302910.png

 

 

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
If this helped, please give Kudos or mark it as a Solution .
Best regards,
Kedar
Connect on LinkedIn
SamWiseOwl
Community Champion
Community Champion

Hi @Justas4478 

Calendar([Date1], [Date2]) creates a list between X dates.

If you want to add a column it sounds similar to calculating the financial year.

There is a full blog here: https://www.wiseowl.co.uk/blog/s2947/calendarauto-table.htm

 

Financial Year = IF(

[Date] >= DATE(Year([Date]), 6, 1),

Year([Date]) & "/" & RIGHT(Year([Date]) +1,2), //Change these to what you need

Year([Date])-1 &"/" & RIGHT(Year([Date]),2)

)


If you are happy with this answer please mark as a solution for others to find !

Kudos are always appreciated! Check out our free Power BI video courses.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.