Forum Discussion

topkatt's avatar
topkatt
Frequent Visitor
8 years ago

Dynamically Retrieve Last Observation per ID

Hi All,

 

I'm trying to create a table that has the last observation for each ID in my data, relative to the current value in a date slicer.

 

Sample data below, thanks for your help!

 

 

IDTypeDateOtherVars
23CREATED10/23/2017 7:39:30 AMFunData
23UPDATED12/28/2017 9:23:01 PMFunData
23DELIVERED5/18/2018 4:27:10 PMFunData
32CREATED10/31/2017 10:56:25 AMFunData
32UPDATED12/31/2017 9:10:58 PMFunData
32DELIVERED6/16/2018 4:26:31 PMFunData
71CREATED5/22/2018 4:14:09 PMFunData
71CANCELED5/22/2018 5:19:00 PMFunData
217CREATED11/29/2017 7:41:00 AMFunData
217UPDATED12/28/2017 9:23:01 PMFunData
217DELIVERED5/19/2018 4:27:45 PMFunData
227CREATED12/15/2017 8:02:19 AMFunData
227RESCHEDULED12/21/2017 8:42:59 PMFunData
227UPDATED12/28/2017 9:27:24 PMFunData
227RESCHEDULED1/16/2018 1:50:29 PMFunData
227UPDATED1/17/2018 1:36:26 PMFunData
227DELIVERED4/6/2018 2:03:02 PMFunData
227CREATED10/18/2017 8:16:00 AMFunData
227UPDATED12/28/2017 9:45:29 PMFunData
227RESCHEDULED1/1/2018 4:40:54 PMFunData
227UPDATED1/3/2018 6:05:40 AMFunData
227DELIVERED4/6/2018 1:57:48 PMFunData

11 Replies

  • If you search through the forums this question is asked repeatedly. you need to use a caluclated COLUMN with Earlier

    • topkatt's avatar
      topkatt
      Frequent Visitor

      Seward12533 wrote:

      If you search through the forums this question is asked repeatedly. you need to use a caluclated COLUMN with Earlier


       

      I honestly have combed through these forums, and have found similar questions but none that seem to answer this specific issue. If you happen to know of one, do you mind pointing me to it?

    • topkatt's avatar
      topkatt
      Frequent Visitor

      Ashish_Mathur wrote:

      Hi,

       

      What result are you expecting?


       

      As an example, if I were to have the date slicer set to 5/15/2018, I would expect the data in my original post to look like this:

      IDTypeDateOtherVars
      23UPDATED12/28/2017 9:23:01 PMFunData
      32UPDATED12/31/2017 9:10:58 PMFunData
      217UPDATED12/28/2017 9:23:01 PMFunData
      227DELIVERED4/6/2018 2:03:02 PMFunData

       

      • Seward12533's avatar
        Seward12533
        Solution Sage

        For this you want a disconnected slicer to harvest the date value for the target date. You can due this by usins the VALUES function to create a table (NEW TABLE form the modeling tab) DateSelection = VALUES(date[date]) but don't relate it to other tables in you  model. thenuse SELECTEDVALUE in a measure to harvest the user choice or define a default (would recommend MAX date from your fact table.  SELECTEDDATE = SELECTEDVALIUE(DateSelection[DATE},MAX(table[Date])

         

        Then  add a column to that compare the date of the row to the SELECTEDDATE and then use the Matrix/Table visual filters to only include the rows where the check column you  added is true.