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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
sravani9920
Frequent Visitor

at what Index the value occurred again?

Hi Guys,

Please help me out,

I am providing sample data for you, Here the output should be as Next Index column  using PQE.

Thanks in Advacne.

 

numberIndexNext Index
10012 
10023 
1003  
2012 
202  
15012 
15023 
15034 
15045 
1505  
101  
1 ACCEPTED SOLUTION
AlienSx
Super User
Super User

hello, @sravani9920 

let
    Source = your_table,
    f = (tbl) => 
        [new_col = List.Skip(tbl[Index]) & {null},
        out = Table.FromColumns(
            Table.ToColumns(tbl) & {new_col}, 
            Table.ColumnNames(tbl) & {"Next Index"}
        )][out],
    g = Table.Group(Source, "number", {"data", f}),
    z = Table.Combine(g[data])
in
    z

View solution in original post

3 REPLIES 3
dufoq3
Super User
Super User

Hi @sravani9920, different approach.

 

Result:

dufoq3_0-1709409523549.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwUNJRMlSK1YGxjZDYxmC2EUKJEZIKUySdpujixkhsEyS2KdR0iNZYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [number = _t, Index = _t]),
    Ad_NewIndex = Table.Combine(Table.Group(Source, {"number"}, {{"t", each Table.AddColumn(_, "New Index", (x)=> if Number.From(x[Index]) <> Table.RowCount(_) then Number.From(x[Index]) +1 else null, Int64.Type), type table}})[t])
in
    Ad_NewIndex

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

AlienSx
Super User
Super User

hello, @sravani9920 

let
    Source = your_table,
    f = (tbl) => 
        [new_col = List.Skip(tbl[Index]) & {null},
        out = Table.FromColumns(
            Table.ToColumns(tbl) & {new_col}, 
            Table.ColumnNames(tbl) & {"Next Index"}
        )][out],
    g = Table.Group(Source, "number", {"data", f}),
    z = Table.Combine(g[data])
in
    z

Thank You AlienSX, This was worked.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

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! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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