Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Count if a datetime is distinct

Hello I have a table that looks like this:

 

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

  • 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

4 Replies

  • mahoneypat's avatar
    mahoneypat
    Icon for Microsoft Employee rankMicrosoft 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

  • Anonymous , Try a new measure like

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

  • v-lionel-msft's avatar
    v-lionel-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    Try this measure.

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

     

     

    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.

  • Hi,

    Try this measure

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

    Hope this helps.