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
WJames
New Member

Custom Grouping

 

I'm not even sure if this is possible in PowerQuery. Previously I was doing this in SQL in a cursor, but I'd like a standalone PowerBI solution.  

 

Basically, I'd like a column that specifies which "Trade" each row belongs to. Each time the MaxOpenQuantity = MaxClosedQuantity for each Symbol, the loop iterates. 

 

This is the data set. 

Originalk.png

 

This is the desired outcome


Book1 - Excel 2023-06-09 14.07.52.png

 

Is this achievable in PowerQuery? 

1 REPLY 1
v-yanjiang-msft
Community Support
Community Support

Hi @WJames ,

Sorry I'm not quite clear about the calculation logic of result "Trade". For flag 1, the Max Open Quantity equals Max Closed Quantity, so the Trade increases by 1. But for flag 2, the Max Open Quantity isn't equal to Max Closed Quantity, why the result is 3?

vyanjiangmsft_0-1686552424056.png

Best regards,

Community Support Team_yanjiang

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.

Top Solution Authors