cancel
Showing results for
Did you mean:
Highlighted
Frequent Visitor

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

qConsider the below table:

 id rag date 101 red 01/06/2020 101 red 02/06/2020 103 red 01/06/2020 103 green 02/06/2020 103 green 05/06/2020 101 green 05/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 red amber green 101 2 103 1 1

Desired outcome for 2

 count_latest red amber green 101 1 103 1

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
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

Highlighted
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

Announcements

#### August 2020 Community Challenge: Can You Solve These?

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

#### Community Blog

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

#### 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

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

Top Solution Authors
Top Kudoed Authors