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
Sam7
Advocate II
Advocate II

Number Rows by Group and Order

Hi

I Power Query, how do I number each row of data, so each group is the same number, but I only want the numbering to go upto 5 then start again?

Sam7_0-1697632696857.png

Cheers

2 REPLIES 2
Ahmedx
Super User
Super User

pls try this code

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WqqqqUorVwaQdnZzBtKtnMArt7OiCQoe4QtR5OTphpT0cwZRvgD8KHRmETHn6OAKVxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Group = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Group", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Group"}, {{"Count", each _, type table [Group=nullable text]}}),
    #"Added Index" = Table.AddIndexColumn(#"Grouped Rows", "Index", 1, 1, Int64.Type),
    #"Calculated Modulo" = Table.TransformColumns(#"Added Index", {{"Index", each if  Number.Mod(_, 5)=0 then 5 else Number.Mod(_, 5) , type number}}),
    #"Removed Columns" = Table.RemoveColumns(#"Calculated Modulo",{"Group"}),
    #"Expanded Count" = Table.ExpandTableColumn(#"Removed Columns", "Count", {"Group"}, {"Group"})
in
    #"Expanded Count"
lbendlin
Super User
Super User

Use GroupKind.Local and Modulus.

 

If you like more help please provide the sample data in a usable format, not as a screenshot.

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.