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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Power query | Deriving dates

Hi there,

I have a data set where there are duplicates becuase students were transferred to the same course 2 times.

For reporting I need to pick up the start date from the row where they first started the course. The end date should be picked from the End date coulmn , it should be the maximum date. I tried using min day and max day with grouping. The issue is when the student is active end date should be blank ,but it brings the max date from the group. System is doing what's correct,but I need to the blank value to be returned.

Eg:

StudentStudent IDStart DateEnd DateCourse nameStatus
John CID000832/09/2022 0:002/01/2023 0:00Certificate IV in BA 183 NTransfer to Complete a Related Course
John CID000833/01/2023 0:0017/01/2023 0:00Certificate IV in BA 183 (22)Completed
John CID000837/03/2022 0:001/09/2022 0:00Certificate IV in BA 183Transfer to Complete a Related Course
Amy AID098282/11/2022 0:002/01/2023 0:00Certificate IV in BA 191 NTransfer to Complete a Related Course
Amy AID0982824/01/2023 0:00 Certificate IV in BA 191(22)Active
Amy AID098286/07/2022 0:0019/10/2022 0:00Certificate IV in BA 191Transfer to Complete a Related Course


John C returns the correct end date as 17/01/2023
Amy A returns 01/01/2023 , but I want it to return blank. How can I do it in power query? Any help is appreciated. Thanks!

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

 

You can add a custom column that returns 1 if there is a blank in the end date, otherwise 0.

vstephenmsft_0-1677057605062.png

Then group by as follows,

vstephenmsft_1-1677057639091.png

vstephenmsft_2-1677057656377.png

Add a custom column to get the real max date.

vstephenmsft_3-1677057726645.png

 

vstephenmsft_4-1677057733629.png

Romove unneeded columns and expand [All Rows] to keep original rows.

vstephenmsft_5-1677057789832.png

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.           

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.