cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Create a measure for prior and latest count based on last date

qConsider the below table:

idragdate
101red01/06/2020
101red02/06/2020
103red01/06/2020
103green02/06/2020
103green05/06/2020
101green05/06/2020

 

I'm looking to create two measures:

  1. one that tallies the count of all id except the latest submission date (05/06/2020 in this case)
  2. another that only tallies the latest  date

Desired outcome for 1

count_prior   
 redambergreen
1012  
1031 1

 

Desired outcome for 2

count_latest   
 redambergreen
101  1
103  1

 

Thank you in advance

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: Create a measure for prior and latest count based on last date

Here are two expressions that should work.

 

Count Latest =
VAR __maxdate =
    CALCULATE ( MAX ( 'Table'[date] ), ALLSELECTED ( 'Table' ) )
RETURN
    CALCULATE ( COUNT ( 'Table'[id] ), 'Table'[date] = __maxdate )


Count Prior =
VAR __maxdate =
    CALCULATE ( MAX ( 'Table'[date] ), ALLSELECTED ( 'Table' ) )
RETURN
    CALCULATE ( COUNT ( 'Table'[id] ), 'Table'[date] < __maxdate )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 

View solution in original post

1 REPLY 1
Highlighted
Community Champion
Community Champion

Re: Create a measure for prior and latest count based on last date

Here are two expressions that should work.

 

Count Latest =
VAR __maxdate =
    CALCULATE ( MAX ( 'Table'[date] ), ALLSELECTED ( 'Table' ) )
RETURN
    CALCULATE ( COUNT ( 'Table'[id] ), 'Table'[date] = __maxdate )


Count Prior =
VAR __maxdate =
    CALCULATE ( MAX ( 'Table'[date] ), ALLSELECTED ( 'Table' ) )
RETURN
    CALCULATE ( COUNT ( 'Table'[id] ), 'Table'[date] < __maxdate )

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat

 

View solution in original post

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors