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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
baadshah
Frequent Visitor

Create custom date period (new column/slicer) from and to date ranges

Hi, 

 

I have created a new table with a list of dates starting from the 15/12/2019 going to 14/12/2022 using the below function:

Calender = CALENDAR(DATE(2018,12,15),DATE(2025,12,14))

 

I would like to create a new column on the same table with my own custom period for example:

 

15th Dec to 14th of Jan = "Period 1"

15th Jan to  14th Feb = "Period 2"
15th Feb to 14th Mar = "Period 3"

and so forth. 

 

My calender starts from the 15th Dec. 

 

The year element of the date will will be a seperate filter so the above period can be filtered by year. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @baadshah ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a alculated column.

CustomPeriod = 
VAR CurrentDate = 'Calender'[Date]
VAR _Year = YEAR(CurrentDate)
VAR _Month = MONTH(CurrentDate)
VAR _Day = DAY(CurrentDate)

RETURN

SWITCH(
        TRUE(),
        OR(_Day >= 15 && _Month = 12 , _Day < 15 && _Month = 1), "Period 1",
        _Day >= 15 && MONTH('Calender'[Date]) = _Month , "Period"&" " &_Month+1,
        _Day < 15 && MONTH('Calender'[Date]) = _Month,"Period"& " " &_Month
    )

(3) Then the result is as follows.

vtangjiemsft_0-1689841898803.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @baadshah ,

 

According to your description, here are my steps you can follow as a solution.

(1) My test data is the same as yours.

(2) We can create a alculated column.

CustomPeriod = 
VAR CurrentDate = 'Calender'[Date]
VAR _Year = YEAR(CurrentDate)
VAR _Month = MONTH(CurrentDate)
VAR _Day = DAY(CurrentDate)

RETURN

SWITCH(
        TRUE(),
        OR(_Day >= 15 && _Month = 12 , _Day < 15 && _Month = 1), "Period 1",
        _Day >= 15 && MONTH('Calender'[Date]) = _Month , "Period"&" " &_Month+1,
        _Day < 15 && MONTH('Calender'[Date]) = _Month,"Period"& " " &_Month
    )

(3) Then the result is as follows.

vtangjiemsft_0-1689841898803.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Sahir_Maharaj
Super User
Super User

Hello @baadshah,

 

Can you please try:

CustomPeriod =
VAR StartMonth = MONTH([Date])
VAR StartDay = DAY([Date])
VAR EndMonth = IF(StartMonth = 12, 1, StartMonth + 1)
VAR EndDay = IF(StartMonth = 12, 14, StartDay - 1)
VAR PeriodNumber = IF(StartMonth = 12, 1, StartMonth)

RETURN
    "Period " & PeriodNumber

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Hi @Sahir_Maharaj. Thank you for getting back to me. 

This function may need a tweak because it's displaying "Period 1" from 15/12/2018 to 31/1/2019. I need it to display:


15/12/2018 to 14/1/2019 as "Period 1" 
15/2/2019 to 14/3/2019 as "Period 2"
and so forth

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.