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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
drogzy
Helper I
Helper I

Creating a custom column to return max value from another column in the same table

Hi all, 

 

Here is what I have and I am trying to add the bolded column as a custom column:

 

IDStartEndRigA Job
123452022-02-10 8:00 AM2022-02-13 10:00 AMDelta 10null
123452022-02-12 8:00 AM2022-2-16 10:00 AMDelta 62022-02-12 8:00 AM

 

As you can see, I want the A Job column to return the max value of the start column. Now I do not want to group them because it will break my direct query to sql. Looking for help in how to use power query to write the correct formula for the column. 

 

Thank you 

2 ACCEPTED SOLUTIONS
BA_Pete
Super User
Super User

Hi @drogzy ,

 

To do this over the whole table you would add something like this to a custom column:

 

List.Max(previousStepName[Start])

 

 

To do it over groups, over each [ID] for example, you will have to group the table, otherwise Power Query has no concept of where you want to limit the operation.

 

You can do this while maintaining folding as follows:

- Duplicate your query and disable load for this new query.

- Implement the simple group on this new table i.e. Group By [ID], MAX [Start] as aggregate column.

- Merge your grouped query to your original query using LEFT OUTER on original[ID] = grouped[ID].

 

If you look at the Native Query for your original query now, you will see that a subquery is being sent to the server for the grouped table and everything takes place server-side i.e. the query is fully folded.

 

Pete

 

 



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

Anonymous
Not applicable

You could do this:
1) sort the table by groups and by date;
2) add an index column {0,1,2, ... rowcount}, call it "idx";
3) add a column calculated with the following logic if [Added Index] {[idx]} [ID] = [Added Index] {[idx] +1} [ID] then null else [start]

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

You could do this:
1) sort the table by groups and by date;
2) add an index column {0,1,2, ... rowcount}, call it "idx";
3) add a column calculated with the following logic if [Added Index] {[idx]} [ID] = [Added Index] {[idx] +1} [ID] then null else [start]

BA_Pete
Super User
Super User

Hi @drogzy ,

 

To do this over the whole table you would add something like this to a custom column:

 

List.Max(previousStepName[Start])

 

 

To do it over groups, over each [ID] for example, you will have to group the table, otherwise Power Query has no concept of where you want to limit the operation.

 

You can do this while maintaining folding as follows:

- Duplicate your query and disable load for this new query.

- Implement the simple group on this new table i.e. Group By [ID], MAX [Start] as aggregate column.

- Merge your grouped query to your original query using LEFT OUTER on original[ID] = grouped[ID].

 

If you look at the Native Query for your original query now, you will see that a subquery is being sent to the server for the grouped table and everything takes place server-side i.e. the query is fully folded.

 

Pete

 

 



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.