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
astarkey
Frequent Visitor

count anything OLDER than previous month

any help here will be most appreciated!!

 

I'm trying to create a measure that will count records older than the previous month..

 

So if today anything older than the 1st of March (feb and back) I can do this in a card with filters quite easily, by setting a date, something I then have to alter at the start of each month to keep the number correct...

 

However I don't want to do that and I also need the measure to help create a percentage figure.

 

I've tried.....

 

older than previous month = CALCULATE(DISTINCTCOUNT(AllJobView[JTJobNo]), < PREVIOUSMONTH('AllJobView'[jtpromisedate]))

 

but it doesnt like the "<"

 

When I remove it, I get an error saying that the specified column is not a date type (this is probably a totally seperate issue... It is a date field)

 

but no luck

 

i'm basically trying to count jobs that are feb and older, then next month march and older etc.... but want to do this without manual filter setting each month.

 

cheers

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi there,

 

You can get away without creating a Date table but you might want to consider adding one later on.

Here are a couple of options just using your AllJobView table:

 

 

older than previous month =
CALCULATE (
    DISTINCTCOUNT ( AllJobView[JTJobNo] ),
    AllJobView[jtpromisedate] <= EOMONTH ( TODAY (), -2 )
)
Count before previous month = 
CALCULATE ( 
    DISTINCTCOUNT ( AllJobView[JTJobNo] ),
    DATESBETWEEN ( AllJobView[jtpromisedate], BLANK(), EOMONTH( TODAY(), -2 ) )
)

 

Regards,

Owen

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

Hi there,

 

You can get away without creating a Date table but you might want to consider adding one later on.

Here are a couple of options just using your AllJobView table:

 

 

older than previous month =
CALCULATE (
    DISTINCTCOUNT ( AllJobView[JTJobNo] ),
    AllJobView[jtpromisedate] <= EOMONTH ( TODAY (), -2 )
)
Count before previous month = 
CALCULATE ( 
    DISTINCTCOUNT ( AllJobView[JTJobNo] ),
    DATESBETWEEN ( AllJobView[jtpromisedate], BLANK(), EOMONTH( TODAY(), -2 ) )
)

 

Regards,

Owen

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Top Man!!

This simple looking fix is going to help me across a number of my reports! Cheers

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.