So I promise I've done my best combing through these forums looking for an aswer to my question, but haven't been able to find a resolution that fits my data.
What I Have
I've got a table 'Table' with three relevant fields: [ID], [Type], and [Date]. There are other fields I'm interested in analyzing, but my problem can be solved just discussing these three. Example below.
In my report, I have a date slicer, though it is coming from a seperate table 'DateTable', which has a single column [JustDate] of distinct dates (not times) from 'Table'[Date]. Example below.
It's important to note that 'DateTable' is NOT linked to 'Table'
What I'm Trying To Do
I need to create several metrics based on the last row of each [ID] for which the [Date] is earlier than the currently selected 'DateTable'[JustDate]. I.e. I'd like to create a new table 'NewTable' that has gone through the following steps:
1. Filter 'Table' to only records for which 'Table'[Date] < 'DateTable'[JustDate]
2. Group by [ID], keeping the row with the latest [Date].
For example, if the slicer for 'DateTable'[JustDate] were set to 5/1/2018, 'NewTable' would look like this:
What I've Tried
Basically everything I've seen on these forums, save for what appears to be super-advanced work arounds (I'm fairly new to Power BI).
The method that makes the most sense intuituvely is to create 'NewTable' such that
'NewTable' = FILTER(ALL('Table'), 'Table'[Date} < SELECTEDVALUE('DateTable'[JustDate]))
and then proceed to Group By, but I haven't even been able to get the above to produce any data. I've tried several variations of the above approach, as well as a few others I've seen around these forums. Any help is appreciated.
Hi, can you post your sample data as a table or link to a demo workbook? I'm thinking this should work
NewTable = VAR Just_Date = MAX(JustDate[Date]) RETURN
If you struggle with this approach you can create a table of the unique ID number and the MAX Date
NewTable = SUMMARIZE(fact[ID],"Date",CALCULATE(MAX(fact[Date]),Filter(fact,Fact[Date]<=MAX(JustDate[Date]))))
Then you could use LOOKUPVALUE to extract the value to TYPE, OTher, VARS etc based on ID and DATE . While not very efficiecnt its easier conceptually.
Sorry about the data, I've attempted to include it below.
I'm trying your propsed solutions now, will update shortly.
|23||CREATED||10/23/2017 7:39:30 AM||Fun||Data|
|23||UPDATED||12/28/2017 9:23:01 PM||Fun||Data|
|23||DELIVERED||5/18/2018 4:27:10 PM||Fun||Data|
|32||CREATED||10/31/2017 10:56:25 AM||Fun||Data|
|32||UPDATED||12/31/2017 9:10:58 PM||Fun||Data|
|32||DELIVERED||6/16/2018 4:26:31 PM||Fun||Data|
|71||CREATED||5/22/2018 4:14:09 PM||Fun||Data|
|71||CANCELED||5/22/2018 5:19:00 PM||Fun||Data|
|217||CREATED||11/29/2017 7:41:00 AM||Fun||Data|
|217||UPDATED||12/28/2017 9:23:01 PM||Fun||Data|
|217||DELIVERED||5/19/2018 4:27:45 PM||Fun||Data|
|227||CREATED||12/15/2017 8:02:19 AM||Fun||Data|
|227||RESCHEDULED||12/21/2017 8:42:59 PM||Fun||Data|
|227||UPDATED||12/28/2017 9:27:24 PM||Fun||Data|
|227||RESCHEDULED||1/16/2018 1:50:29 PM||Fun||Data|
|227||UPDATED||1/17/2018 1:36:26 PM||Fun||Data|
|227||DELIVERED||4/6/2018 2:03:02 PM||Fun||Data|
|227||CREATED||10/18/2017 8:16:00 AM||Fun||Data|
|227||UPDATED||12/28/2017 9:45:29 PM||Fun||Data|
|227||RESCHEDULED||1/1/2018 4:40:54 PM||Fun||Data|
|227||UPDATED||1/3/2018 6:05:40 AM||Fun||Data|
|227||DELIVERED||4/6/2018 1:57:48 PM||Fun||Data|