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
Incamus
Regular Visitor

Index with repeated values

Dear all, good afternoon.

Can you help me with this problem?

 

Table with the code used:

 

Incamus_0-1681926972625.png

 

let
Fonte = BD_Geral,
#"Outras Colunas Removidas" = Table.SelectColumns(Fonte,{"Nº CTe", "Nome"}),
#"Linhas Classificadas" = Table.Sort(#"Outras Colunas Removidas",{{"Nº CTe", Order.Ascending}}),
#"Linhas Agrupadas" = Table.Group(#"Linhas Classificadas", {"Nº CTe"}, {{"Tranportadoras", each _, type table [Nº CTe=nullable number, Nome=nullable text]}}),
#"Tranportadoras Agregado" = Table.AggregateTableColumn(#"Linhas Agrupadas", "Tranportadoras", {{"Nome", List.Distinct, "Contagem de Tranportadoras.Nome"}}),
#"Contagem de Tranportadoras.Nome Expandido" = Table.ExpandListColumn(#"Tranportadoras Agregado", "Contagem de Tranportadoras.Nome")
in
#"Contagem de Tranportadoras.Nome Expandido"

 

Desired result:

 

Incamus_1-1681927341717.png

As an example of 52, it started with 0 and then went to 1. If there was a third repeated number, it would go to 2, and so on.

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Incamus ,

Please refer the steps below.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUUpMVIrViVYyQjCNEUwTIDMpCc5MTgYzTYHMlBQw0wzITE2FM9PS4MyMDKXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Nº Cte" = _t, #"Contagem de Tranportadoras.Nome" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Nº Cte", Int64.Type}, {"Contagem de Tranportadoras.Nome", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Nº Cte"}, {{"Data", each Table.AddIndexColumn(_, "Index", 0, 1, Int64.Type)}}),
    #"Expanded Data" = Table.ExpandTableColumn(#"Grouped Rows", "Data", {"Contagem de Tranportadoras.Nome", "Index"}, {"Contagem de Tranportadoras.Nome", "Index"})
in
    #"Expanded Data"

vcgaomsft_0-1682040272142.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Incamus ,

Please refer the steps below.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUUpMVIrViVYyQjCNEUwTIDMpCc5MTgYzTYHMlBQw0wzITE2FM9PS4MyMDKXYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Nº Cte" = _t, #"Contagem de Tranportadoras.Nome" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Nº Cte", Int64.Type}, {"Contagem de Tranportadoras.Nome", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Nº Cte"}, {{"Data", each Table.AddIndexColumn(_, "Index", 0, 1, Int64.Type)}}),
    #"Expanded Data" = Table.ExpandTableColumn(#"Grouped Rows", "Data", {"Contagem de Tranportadoras.Nome", "Index"}, {"Contagem de Tranportadoras.Nome", "Index"})
in
    #"Expanded Data"

vcgaomsft_0-1682040272142.png

 

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

The solution worked, thanks @Anonymous 

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.