Forum Discussion
Get last value in group
- 5 years ago
FilipK This will return your first desired table:
Table 2 = VAR __Table = SUMMARIZE('Table (5)',[deviceId],"__time",MAX('Table (5)'[time])) VAR __Table2 = ADDCOLUMNS(__Table,"__Version",MAXX(FILTER('Table (5)','Table (5)'[deviceId] = [deviceId] && [time] = [__time]),[Version])) RETURN __Table2You can use this in a measure like the following:
Measure = VAR __Version = MAX([Version]) VAR __Table = SUMMARIZE(ALL('Table (5)'),[deviceId],"__time",MAX('Table (5)'[time])) VAR __Table2 = ADDCOLUMNS(__Table,"__Version",MAXX(FILTER('Table (5)','Table (5)'[deviceId] = [deviceId] && [time] = [__time]),[Version])) RETURN COUNTROWS(FILTER(__Table2,[__Version] = __Version)) + 0This would be used in a pie chart along with your [Version] column for example.
- 5 years ago
- 5 years ago
FilipK Seems like Lookup Min/Max to me. https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/m-p/985814#M434
For the first table, that seems like a straight MAX measure for the time column in that table. Then just use that to figure out the Version at that time.
- FilipK5 years ago
Resolver I
Greg_Deckler , I think it's another case. But I suppose you proposed that solution since in my the first version of the post, I made a fault in the expected output tables. Sorry for that. I corrected myself already.
My idea is: Get the last time each device sent a message and based on that outcome summarize the versions. At this point I've struggled.
- Greg_Deckler5 years ago
Community Champion
FilipK This will return your first desired table:
Table 2 = VAR __Table = SUMMARIZE('Table (5)',[deviceId],"__time",MAX('Table (5)'[time])) VAR __Table2 = ADDCOLUMNS(__Table,"__Version",MAXX(FILTER('Table (5)','Table (5)'[deviceId] = [deviceId] && [time] = [__time]),[Version])) RETURN __Table2You can use this in a measure like the following:
Measure = VAR __Version = MAX([Version]) VAR __Table = SUMMARIZE(ALL('Table (5)'),[deviceId],"__time",MAX('Table (5)'[time])) VAR __Table2 = ADDCOLUMNS(__Table,"__Version",MAXX(FILTER('Table (5)','Table (5)'[deviceId] = [deviceId] && [time] = [__time]),[Version])) RETURN COUNTROWS(FILTER(__Table2,[__Version] = __Version)) + 0This would be used in a pie chart along with your [Version] column for example.