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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
StuartSmith
Power Participant
Power Participant

Count number of rows from previous month

I have a table that have various coumns including "Start Date".  I am trying to create a measure that will display the number of rows with the "Start Date" as the previous month.  So as an example if we are in Feb 22, I want to display the number of rows that have the start date in Jan 22.

 

I have tried various other solutions found on the web, but cant get any to work.

 

Thanks in advance

1 ACCEPTED SOLUTION

@StuartSmith If that code works then you can update the code like below just to avoid that filter.

Measure = CALCULATE(COUNTROWS('HR Data'), All('Dates'),PREVIOUSMONTH('Dates'[Date]))

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

5 REPLIES 5
StuartSmith
Power Participant
Power Participant

OK, Figured out that there is a page fiilter that is preventing the value from being displayed, although unsure why this page filter would prevent the mesaure from counting/displaying the rows dated for the previous month (Jan) as the page filter is only to show anticipated start dates on or after 01/011/22 and on or before 31/12/22 to is within range.  

 

Can anyone assist?

 

@StuartSmith If that code works then you can update the code like below just to avoid that filter.

Measure = CALCULATE(COUNTROWS('HR Data'), All('Dates'),PREVIOUSMONTH('Dates'[Date]))

 

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

I just figured that by adding "All" it will remove the filters, and show a value, but its the incorrect value. Now that i know the casue (filter), I should be able (hopefully) to get a workaround.

 

StuartSmith
Power Participant
Power Participant

Hi, I tried your solution referrencing the "Date" table which I already had created and that displayed "(Blank)".

Measure = CALCULATE(COUNTROWS('HR Data'), PREVIOUSMONTH('Dates'[Date]))
I therefore tried the below and this also displays (Blank).
Measure = CALCULATE(COUNTROWS('HR Data'), PREVIOUSMONTH('HR Data'[Anticipated Start Date]))
 
Any ideas?
Samarth_18
Community Champion
Community Champion

Hi @StuartSmith ,

 

Please try:-

Measure = CALCULATE(countrow(table), PREVIOUSMONTH('Datetable'[date])) 

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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