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
bkanderso
Helper I
Helper I

Creating A Function To Return Values based On Earliest Date

I have a table in power query and it has multiple students (unique Identifiers) and multiple colu,ns.  I need to write a function that will return the qualification earned during each semester based on the earliest date earned during that semester.  Each student has earned the same qualification multiple times in the same semester.  I am wanting the table to show the qualification earned only once and based on the earliest date it was earned during that semester.  Is this possible?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @bkanderso ,

 

I made a sample data and below is my solution for you reference.

Data:

vstephenmsft_0-1683596952924.png

1.Select the Student column and group by.

vstephenmsft_1-1683597081795.png

vstephenmsft_2-1683597152769.png

vstephenmsft_3-1683597176397.png

2.If you also want to get rows before other columns, expand the All Rows.

vstephenmsft_4-1683597227471.png

vstephenmsft_6-1683597502495.png

3.Add a custom column for filtering.

vstephenmsft_5-1683597491873.png

vstephenmsft_8-1683597530082.png

4.Filter to keep the rows with 1.

vstephenmsft_7-1683597521659.png

vstephenmsft_9-1683597558664.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.           

 

View solution in original post

3 REPLIES 3
bkanderso
Helper I
Helper I

Thank you, this helps.

AlienSx
Super User
Super User

Hi, @bkanderso add "semester" into grouping (along with "student") if needed

groups = Table.Group(Source, {"Student"}, {{"all", each Table.Min(_, "Date")}}),
z = Table.FromRecords(groups[all])

 

Anonymous
Not applicable

Hi @bkanderso ,

 

I made a sample data and below is my solution for you reference.

Data:

vstephenmsft_0-1683596952924.png

1.Select the Student column and group by.

vstephenmsft_1-1683597081795.png

vstephenmsft_2-1683597152769.png

vstephenmsft_3-1683597176397.png

2.If you also want to get rows before other columns, expand the All Rows.

vstephenmsft_4-1683597227471.png

vstephenmsft_6-1683597502495.png

3.Add a custom column for filtering.

vstephenmsft_5-1683597491873.png

vstephenmsft_8-1683597530082.png

4.Filter to keep the rows with 1.

vstephenmsft_7-1683597521659.png

vstephenmsft_9-1683597558664.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.