Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hello I have the data below
Ideally I would like to select for each PerID the containing the latest date. I've tried groupby in query editor (groupby perID then select Max date and all rows, however when I expand the table to get the DBID field I end up with duplicates
Any pointers gratefully recieved
Cheers
Neil
| PerID | DBID | StartDate |
| PER10007 | 33918908 | |
| PER10007 | 33928550 | 02/08/2010 23:00 |
| PER10022 | 33900446 | 09/05/2017 00:00 |
| PER10022 | 33918909 | |
| PER10022 | 33923009 | |
| PER10022 | 33928551 | 06/11/2007 00:00 |
| PER10029 | 33873682 | 06/07/2020 23:00 |
| PER10029 | 33897224 | 01/02/2023 00:00 |
| PER10029 | 33900447 | 03/10/2018 00:00 |
| PER10029 | 33900448 | 08/10/2018 00:00 |
| PER10029 | 33900449 | 18/10/2018 00:00 |
| PER10029 | 33900450 | 01/11/2018 00:00 |
| PER10029 | 33900451 | 05/04/2019 00:00 |
| PER10029 | 33900452 | 22/07/2019 00:00 |
| PER10029 | 33900453 | 13/08/2019 00:00 |
| PER10029 | 33910860 | 15/09/2020 00:00 |
| PER10029 | 33912610 | 06/02/2023 00:00 |
| PER10029 | 33912611 | 12/04/2023 00:00 |
| PER10029 | 33917448 | 12/04/2023 00:00 |
Solved! Go to Solution.
Hi @neilmc ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create a table.
Table 2 =
var _a=ADDCOLUMNS('Table',"max", CALCULATE(MAX('Table'[StartDate]),FILTER('Table','Table'[PerID]=EARLIER('Table'[PerID]))))
var _b= FILTER(_a,[StartDate]=[max])
return SELECTCOLUMNS(_b,"PerID",[PerID],"DBID",[DBID],"StartDate",[StartDate])
(3) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @neilmc ,
According to your description, here are my steps you can follow as a solution.
(1) My test data is the same as yours.
(2) We can create a table.
Table 2 =
var _a=ADDCOLUMNS('Table',"max", CALCULATE(MAX('Table'[StartDate]),FILTER('Table','Table'[PerID]=EARLIER('Table'[PerID]))))
var _b= FILTER(_a,[StartDate]=[max])
return SELECTCOLUMNS(_b,"PerID",[PerID],"DBID",[DBID],"StartDate",[StartDate])
(3) Then the result is as follows.
Best Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello - I think I was being I bit of an idiot! It looks like the grouping method worked in power query but the issue was that I had duplicate person ids with exactly the same start date
can you show the result you expect
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 50 | |
| 44 | |
| 42 | |
| 19 | |
| 19 |
| User | Count |
|---|---|
| 69 | |
| 68 | |
| 33 | |
| 32 | |
| 32 |