Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
Anonymous
Not applicable

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]))


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.