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
giordafrancis
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
mahoneypat
Employee
Employee

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

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

1 REPLY 1
mahoneypat
Employee
Employee

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

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.

Top Solution Authors