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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
gcongrove
Frequent Visitor

Need to create an index column that is grouped.

Hello,  

 

I'm not sure what the term is for what I need, im calling it a grouped index column.

I just need to create a column that starts with 1 repeats it 5 times, then moves to 2 repeats 5 times etc. 

Can this be added in query editor rather than in DAX? I need to manipulate the data in Query editor after I figure out how to get the grouped index column created.

Thank you!!


Example

Index
1
1
1
1
1
2
2
2
2
2
3
3
3
3
3
4
4
4
4
4

 

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

OK, try this:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45Wys9LVYrVIUyXlOcTR2cUpaaSxErLLy0ijhELAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each Number.IntegerDivide([Index],6)+1),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type number}})
in
    #"Changed Type1"


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Greg,

This is helpful I think I can make this work!  How did you get the column to stop at "four"? I'm needing to add this column to an existing table and have the index column repeat until the end of the file.

Greg_Deckler
Community Champion
Community Champion

Add an Index colum. Then add a custom column where you likely have a math formula that uses mod and int, hard to remember exactly.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.