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
gcv1999
Helper I
Helper I

Count if a datetime is distinct

Hello I have a table that looks like this:

expirations.png

 

I'd like to count the expirations that are past due. In the above case for id ending in 774, there would only be 1 expiration despite having multiple certifications expiring on the same day/time. In total for the above table, there would be two expirations not 4. 

 

However, I do not want to look at only distinct date/times because a date and time could apply to multiple ids.

 

What measure could I write to achieve this? Thank you

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

You could try a measure expression like this to get your result

 

Expirations =
COUNTROWS (
FILTER (
SUMMARIZE ( Table, Table[id], Table[expiration] ),
Table[expiration] < TODAY ()
)
)

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

Regards,

Pat

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

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Try this measure

Measure = Calculate(Distinctcount(Data[id]),filter(Data,Data[expiration]<today()))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-lionel-msft
Community Support
Community Support

Hi @gcv1999 ,

 

Try this measure.

Measure = 
CALCULATE(
    DISTINCTCOUNT('Sheet1 (2)'[expiration]),
    ALLEXCEPT( 'Sheet1 (2)', 'Sheet1 (2)'[id] )
)

 ccc1.PNG

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mahoneypat
Employee
Employee

You could try a measure expression like this to get your result

 

Expirations =
COUNTROWS (
FILTER (
SUMMARIZE ( Table, Table[id], Table[expiration] ),
Table[expiration] < TODAY ()
)
)

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

Regards,

Pat

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


amitchandak
Super User
Super User

@gcv1999 , Try a new measure like

countx(summarize(Table, table[id],table[expiration]),[id])

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.