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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
yhong16
Regular Visitor

Fill down with index value

I am trying to fill down in null value, i have tried group by and it does not work. As i have simlar value in the same column. Last column is what i want. I currently have first 2 columns. Any idea how to achieve this? 

CustomIndex.1  What I want
10  1
21  2
32  3
43  4
54  5
65  6
76  7
87  8
78  7
89  8
610  6
711  7
null12  8
null13  9
null14  10
415  4
516  5
null17  6
null18  7
null19  8
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText(
          "Vc5LDsAgCATQu7B2IShKz2K8gemu9++UJiTs3vAJrEVMhSrtskggdjVIXB1qLoW6a0DqmtBwGTSjZlG7YoNrtPm/cj/nfElSain1+II13uCRZmZKlhLu7xc=", 
          BinaryEncoding.Base64
        ), 
        Compression.Deflate
      )
    ), 
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [Custom = _t, Index.1 = _t]
  ), 
  #"Changed Type" = Table.TransformColumnTypes(
    Source, 
    {{"Index.1", Int64.Type}, {"Custom", Int64.Type}}
  ), 
  #"Replaced Value" = Table.ReplaceValue(
    #"Changed Type", 
    each [Custom], 
    (k) =>
      if k[Custom] = null then
        let
          t = Table.Last(
            Table.SelectRows(#"Changed Type", each [Index.1] < k[Index.1] and [Custom] <> null)
          )
        in
          k[Index.1] - t[Index.1] + t[Custom]
      else
        k[Custom], 
    Replacer.ReplaceValue, 
    {"Custom"}
  )
in
  #"Replaced Value"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the Source step with your own source.

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

let
  Source = Table.FromRows(
    Json.Document(
      Binary.Decompress(
        Binary.FromText(
          "Vc5LDsAgCATQu7B2IShKz2K8gemu9++UJiTs3vAJrEVMhSrtskggdjVIXB1qLoW6a0DqmtBwGTSjZlG7YoNrtPm/cj/nfElSain1+II13uCRZmZKlhLu7xc=", 
          BinaryEncoding.Base64
        ), 
        Compression.Deflate
      )
    ), 
    let
      _t = ((type nullable text) meta [Serialized.Text = true])
    in
      type table [Custom = _t, Index.1 = _t]
  ), 
  #"Changed Type" = Table.TransformColumnTypes(
    Source, 
    {{"Index.1", Int64.Type}, {"Custom", Int64.Type}}
  ), 
  #"Replaced Value" = Table.ReplaceValue(
    #"Changed Type", 
    each [Custom], 
    (k) =>
      if k[Custom] = null then
        let
          t = Table.Last(
            Table.SelectRows(#"Changed Type", each [Index.1] < k[Index.1] and [Custom] <> null)
          )
        in
          k[Index.1] - t[Index.1] + t[Custom]
      else
        k[Custom], 
    Replacer.ReplaceValue, 
    {"Custom"}
  )
in
  #"Replaced Value"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the Source step with your own source.

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors