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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.