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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
ErinKlomp
New Member

Power Query index that resets when one column changes

Hi everyone,

 

I am a first time user of Power Query and am stuck. I have no experience with similar software.

 

I want to create an index, which resets to 1 when one column changes value. As an example, this is some of my data. I added the pink row to show what I want to accomplish. I just don't get it. I prefer not to use the advanced editor as I do not understand it (but if someone can give me a foolproof step-by-step, I can try). I have tried many things, but my index keeps ending up to continue counting.

 

If someone can help me explain how to achieve this, I would greatly appreciate this!

evaluatieperiodeidrespondentidIndex
591412572621
591412572632
591412572663
591412572684
591422568981
591422568992
591422569033
591422569044

 

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @ErinKlomp,

 

Group Rows:

dufoq3_0-1721242803078.png

 

Change the code of Grouped rows where you replace _ with Table.AddIndexColumn(_, "Index", 1, 1, Int64.Type) and remove RED part of that code.

dufoq3_1-1721242963472.png

 

= Table.Group(Source, {"evaluatieperiodeid"}, {{"All", each Table.AddIndexColumn(_, "Index", 1, 1, Int64.Type), type table}})

 

 

Expand columns you want (unthick Use original column name as prefix)

dufoq3_2-1721243173514.png

 

You can find whole code with sample data included here (you have to replace whole code with this one via Advanced Editor):

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrU0NDFU0lEyMjU3MjNSitVBEzLGFDLDFLKACxmBhcwsLLEIWaILWRoYYwqZKMXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [evaluatieperiodeid = _t, respondentid = _t]),
    GroupedRows = Table.Group(Source, {"evaluatieperiodeid"}, {{"All", each Table.AddIndexColumn(_, "Index", 1, 1, Int64.Type), type table}})
in
    GroupedRows

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

3 REPLIES 3
ErinKlomp
New Member

@dufoq3 Thank you so much!!!! It worked perfectly!

You're welcome.


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

dufoq3
Super User
Super User

Hi @ErinKlomp,

 

Group Rows:

dufoq3_0-1721242803078.png

 

Change the code of Grouped rows where you replace _ with Table.AddIndexColumn(_, "Index", 1, 1, Int64.Type) and remove RED part of that code.

dufoq3_1-1721242963472.png

 

= Table.Group(Source, {"evaluatieperiodeid"}, {{"All", each Table.AddIndexColumn(_, "Index", 1, 1, Int64.Type), type table}})

 

 

Expand columns you want (unthick Use original column name as prefix)

dufoq3_2-1721243173514.png

 

You can find whole code with sample data included here (you have to replace whole code with this one via Advanced Editor):

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrU0NDFU0lEyMjU3MjNSitVBEzLGFDLDFLKACxmBhcwsLLEIWaILWRoYYwqZKMXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [evaluatieperiodeid = _t, respondentid = _t]),
    GroupedRows = Table.Group(Source, {"evaluatieperiodeid"}, {{"All", each Table.AddIndexColumn(_, "Index", 1, 1, Int64.Type), type table}})
in
    GroupedRows

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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