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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors