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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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