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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
henry24007
Helper I
Helper I

add index every n th row in PQ

I have a table look like this

 

departmentcol1col2yearindex
a1220211
b3420212
a5620223
b7820224

What I want to do is 

departmentcol1col2yearindex
a1220211
b3420212
a5620221
b7820222

 

how can I turn the index to what I want

 

Thanks

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@henry24007 , refer the solution by curbal

https://www.youtube.com/watch?v=7CqXdSEN2k4

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

3 REPLIES 3
Hariharan_R
Solution Sage
Solution Sage

Hi @henry24007 

You can use your year column with group by.

 

Ref - https://radacad.com/create-row-number-for-each-group-in-power-bi-using-power-query

Thanks

Hari

Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


My Blog :: YouTube Channel :: My Linkedin


Jihwan_Kim
Super User
Super User

Hi,

I am not sure whether I understood your question correctly, but please check the below and the attached pbix file.

All steps are described in Power Query Editor in the attached file.

 

Advanced editor in PQ.

 

let
    Source = Source,
    #"Grouped Rows" = Table.Group(Source, {"year"}, {{"Table", each Table.AddIndexColumn( _, "Index", 1, 1)}}),
    #"Expanded Table" = Table.ExpandTableColumn(#"Grouped Rows", "Table", {"department", "col1", "col2", "Index"}, {"department", "col1", "col2", "Index"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded Table",{{"year", Int64.Type}, {"department", type text}, {"col1", Int64.Type}, {"col2", Int64.Type}, {"Index", Int64.Type}})
in
    #"Changed Type"

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

amitchandak
Super User
Super User

@henry24007 , refer the solution by curbal

https://www.youtube.com/watch?v=7CqXdSEN2k4

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.