cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
marmarfe
New Member

Group by - last date

Hi, 

 

I'm quite new on the use of Power BI and I'm stuck trying to solve this probelm since almost one week. 

 

I have a table containing registers of different flights, it looks as follow:

 

FlightIDCategoryDateAircraft RegistrationAirport DEPAirport ARR
34406Production06-JanEEEHUENHUEN
34430Production07-JanEEEHUENHUEN
34433Production08-JanEEEHUENHUEN
34458Production09-JanEEEHUENHUEN
34589Production12-JanEEEHUENHUEN
34383Production05-JanDDDEBAWEBAW
34407Production06-JanDDDEBAWEBAW
34434Ferry08-JanDDDEBAWEHTE
34515Ferry11-JanDDDEBAWEGTC
34579Ferry11-JanDDDEGTCEBAW
34591Test flight EQT12-JanDDDEBAWEBAW
34368Ferry05-JanCCCEBAWEHTE
34232Production02-JanBBBHUENHUEN
34320Production03-JanBBBHUENHUEN
34346Production04-JanBBBHUENHUEN
34231Ferry01-JanAAAEDDGEBAW
34390Production05-JanAAAEBAWEDDG
34394Production06-JanAAAEDDGEDDG
34427Production06-JanAAAEDDBEBAW

 

What I need is to know where each plane has landed last time, the result should be a table with 3 columns as it is shown on the sample below:

 

DateAircraft RegistrationAirport ARR
06-JanAAAEBAW
04-JanBBBHUEN
05-JanCCCEHTE
12-JanDDDEBAW
12-JanEEEHUEN

 

I have tried to use the function Group By (registration) selection the MAX value of the date, but I cannot add the column airport because I have to include an "expresion", getting the wrong result. I have  also tried with the function summarize, but I haven't succed.

 

Any idea about how to solve this problem?

 

Thanks a lot!

 

Marcos

1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

@marmarfe

 

Hi, in Query Editor, you can do

 

1. Duplicate the Query

 

2. Group By:

 

img1.png

 

3. Merge Both Tables

 

img2.png

 

4. Expand it select the columns that you desire

 

img3.png

 

5. Ready

 

img4.png

 

Regards

 

Victor

Lima - Peru




Lima - Peru

View solution in original post

5 REPLIES 5
Vvelarde
Community Champion
Community Champion

@marmarfe

 

Hi, in Query Editor, you can do

 

1. Duplicate the Query

 

2. Group By:

 

img1.png

 

3. Merge Both Tables

 

img2.png

 

4. Expand it select the columns that you desire

 

img3.png

 

5. Ready

 

img4.png

 

Regards

 

Victor

Lima - Peru




Lima - Peru

View solution in original post

Thank You! Group By is an excellent solution. Much respect to your name Vverlarde. Mucas Gracias.

Thanks Victor, It works now!!!

 

I was focus on the columns that I wanted to have on my output table, and I never consider to link them by the ID number.

 

Regards

@marmarfe,

Glad to hear the issue is solved, you can accept appropriate reply as answer to close this thread.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
parry2k
Super User
Super User

Add two measures, one for latest date and other for latest arrival airport

 

Latest Date = CALCULATE(MAX(Table1[Date]), Filter(ALLSELECTED(Table1[Aircraft Registration]), Table1[Aircraft Registration] = MAX(Table1[Aircraft Registration])))

Last Arrival Airport = Calculate(FIRSTNONBLANK(Table1[Airport ARR],1), Filter(Table1, Table1[Latest Date] = Table1[Date]))





Did I answer your question? Mark my post as a solution.

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors