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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Help counting rows based on previous month date

Hey all,

 

In our Org we report 1 month in arrers. So I need to write a DAX measure that looks for "recorded date" for the previous month.

 

Im not sure what if any functions there are in PBI that evaluates current month? I need something to the effect of...

 

Last month Total = Countrows(This month - 1)

 

Thanks,

J

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous , Try with date table

MTD Sales = CALCULATE(countrows(Sales[Table]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(countrows(Sales[Table]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

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

View solution in original post

Hi @Jaydpie ,

First, you must create a relationship between the fact table and the date dimension.

Next, create the above measures in the file.

3-1.PNG

Here is my test file for your reference.

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , Try with date table

MTD Sales = CALCULATE(countrows(Sales[Table]),DATESMTD('Date'[Date]))
last MTD Sales = CALCULATE(countrows(Sales[Table]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

 

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

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
Anonymous
Not applicable

Hey,

 

Not sure where to apply these? I have a date table and my data has a "date claim reported" column.

 

I am a noob to PBI

Hi @Jaydpie ,

First, you must create a relationship between the fact table and the date dimension.

Next, create the above measures in the file.

3-1.PNG

Here is my test file for your reference.

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

Helpful resources

Announcements
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.

June 2025 community update carousel

Fabric Community Update - June 2025

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