Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Displaying data by latest timestamp

Hi there,

 

I am building a report to visualize number of patients on each hospital unit. This data is inputted by nursing staff throughout same day. The idea is to create a table that shows last inputted number by unit. I can filter it by MAX date but not by last timestamp. Wondering if anyone can help me out? Thanks so much!!

 

Input:

Number of Patients | Unit |Created

10                              A        6/6/2020 13:00

15                              A         6/6/2020 15:00

13                              A         6/6/2020 16:00

8                                B         6/6/2020 09:00

7                                B         6/6/2020 09:15

 

Output:

Number of Patients |Unit |Created

13                              A       6/6/2020 16:00

7                                B         6/6/2020 09:15

  • Hi Anonymous ,

     

    You can create a visual level filter:

     

    Measure = IF(MAX('Table'[Created]) = CALCULATE(MAX('Table'[Created]),ALLEXCEPT('Table','Table'[Unit])),1,0)

     

     

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

     

    Best Regards,

    Dedmon Dai

6 Replies

  • Anonymous add following measure to get the result:

     

    Measure = 
    CALCULATE ( 
        SUM ( 'Table (2)'[Number of Patients] ), 
        KEEPFILTERS (
            TOPN ( 1, ALLSELECTED ( 'Table (2)'[Created] ), CALCULATE ( MAX ( 'Table (2)'[Created] ) ), DESC ) 
        ) 
    )

     

     

    Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS  I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi parry2k I tried the formula but it's giving a total sum of number of patients on 5C rather than the most recent entry. 

     

     

  • Anonymous do you have two records for the same timestamp on 5c? Not sure if I understood your question. Maybe share sample data where you see this issue to further look into it.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi parry2k 

       

      I have attached the data - I am trying to display the latest census and latest projected census by unit

       

      For 8C - I would like to display current census inputted 9 minutes ago

      and 5C it would be the current census inputted yesterday at 5:02 PM

       

      Beyond the table, would it be possible to use the measure as a report level filter? I appreciate your input! Thanks so much!

       

       

       

       

  • v-deddai1-msft's avatar
    v-deddai1-msft
    Community Support

    Hi Anonymous ,

     

    You can create a visual level filter:

     

    Measure = IF(MAX('Table'[Created]) = CALCULATE(MAX('Table'[Created]),ALLEXCEPT('Table','Table'[Unit])),1,0)

     

     

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

     

    Best Regards,

    Dedmon Dai