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
danielcarreira1
Regular Visitor

Column name to show date of prior month that when report is running

Hi all,

I am very new to PowerBI but i am building a report where one of the columns has to show the date in the format 'yyyy-mm-dd' for the prior month of when it's running, so if in march 2021 should show the first day of February 2021 in the format referred previously.

 

Appreciate assistance.

 

Best Regards,

Daniel

1 ACCEPTED SOLUTION
v-alq-msft
Community Support
Community Support

Hi, @danielcarreira1 

 

Based in your description, I created data to reproduce your scenario. The pbix file is attached in the end. 

Table:

a1.png

 

You may create a calculated column or a measure as below.

Calculated column:

Result Column = EOMONTH([Date],-2)+1

Measure:

Result Measure = EOMONTH(SELECTEDVALUE('Table'[Date]),-2)+1

 

Result(You can modify the format in 'Column tools'):

a3.png

a2.png

 

Or you may go to 'Query Editor'm create a custom column with the following m codes.

Date.AddDays( Date.EndOfMonth( Date.AddMonths([Date],-2) ),1)

 

Then you can modify the format as you want in Power BI Desktop. Here is the result.

a5.png

 

Best Regards

Allan

 

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

2 REPLIES 2
v-alq-msft
Community Support
Community Support

Hi, @danielcarreira1 

 

Based in your description, I created data to reproduce your scenario. The pbix file is attached in the end. 

Table:

a1.png

 

You may create a calculated column or a measure as below.

Calculated column:

Result Column = EOMONTH([Date],-2)+1

Measure:

Result Measure = EOMONTH(SELECTEDVALUE('Table'[Date]),-2)+1

 

Result(You can modify the format in 'Column tools'):

a3.png

a2.png

 

Or you may go to 'Query Editor'm create a custom column with the following m codes.

Date.AddDays( Date.EndOfMonth( Date.AddMonths([Date],-2) ),1)

 

Then you can modify the format as you want in Power BI Desktop. Here is the result.

a5.png

 

Best Regards

Allan

 

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

amitchandak
Super User
Super User

@danielcarreira1 , You can try measure like

eomonth(max(Date[Date]),-2)+1

 

or

 

eomonth(today(),-2)+1

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.