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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
PBI_newuser
Post Prodigy
Post Prodigy

How to create a column for a customize month

Hi, how to create a Month column if the date is N-10 days prior current month and N-10 days prior next month.

For example: 

Month

Start Date

(N-10 days prior current month)

End Date

(N-10 days prior next month)

July21st June21st July
August22nd July21st August
September22nd August20th September

 

 

1 ACCEPTED SOLUTION

Please try this column expression instead.

 

MonthColumn =
VAR thisdate = 'Date'[Date]
VAR daysfromend =
    INT ( EOMONTH ( thisdate0 ) - thisdate )
VAR monthtoformat =
    IF ( daysfromend <= 10EOMONTH ( thisdate1 )thisdate )
RETURN
    FORMAT ( monthtoformat"yyyy-mm" )

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

@PBI_newuser , If you have date

 

Then

Start Date  = eomonth([Date],0) -10

End Date  = eomonth([Date],1) -10

 

If you have month name create a date fist like

 

Date = "01-" & [Month] & "-" & [Year] // you can change data type to date

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak , based on the start and end date, how to create the month column?

I have date field in my table.

 

Month

Start Date

(N-10 days prior current month)

End Date

(N-10 days prior next month)

2021-0721-6-202121-7-2021
2021-0822-7-202121-8- 2021
2021-0922-8-202120-9-2021

You can create a DAX column with an expression like this.  Replace Table with your actual table name.

 

MonthColumn = FORMAT(Table[End Date], "yyyy-mm")
 
Pat




Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi @mahoneypat , actually I wanna group the date by month to calculate the some metrics.

For example, I want to calculate the performance of each team in each month.

If the date falls between start date and end date, then take the month of end date.

 

Date

Month
25-6-20212021-07
15-7-20212021-07
22-7-20212021-08
10-8-20212021-08
31-8-20212021-09
20-9-20212021-09
21-9-20212021-10

 

Please try this column expression instead.

 

MonthColumn =
VAR thisdate = 'Date'[Date]
VAR daysfromend =
    INT ( EOMONTH ( thisdate0 ) - thisdate )
VAR monthtoformat =
    IF ( daysfromend <= 10EOMONTH ( thisdate1 )thisdate )
RETURN
    FORMAT ( monthtoformat"yyyy-mm" )

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thanks @mahoneypat ! It works! 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.