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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
osama_ayoub
Helper III
Helper III

How can Split group of row into some of subsets based on condition?

I have a Table as below 

this table has some items and quantity and price columns 

what I want to do is divide these items to groups where the total sum of  net price for each group does not exceed 2000$ ?

 

osama_ayoub_1-1674558375857.png

 

 

1 REPLY 1
wdx223_Daniel
Super User
Super User

you can try this code, but the efficiency is a problem

NewStep=let a=Table.AddIndexColumn(PreviousStepName,"idx"),b=List.Buffer(a[Net Value]) in Table.Group(a,"idx",{"n",each _},0,(x,y)=>Byte.From(List.Sum(List.Range(b,x,y-x+1))>=2000))

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.