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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
rikofebriyan
New Member

How to create Fill Down with additional index

can someone help me with my problem...  i want to fill down my zero values become additional +1 like index until it reach value of 1 and repeat

 

 

for example i have a table like this

 OK

1
0
0
0
0
1
0
0
0
0
0
1
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0

 

what i expecting is become like this

 

OK

 

OK

1
2
3
4
5
1
2
3
4
5
6
1
2
3
4
1
2
3
4
5
1
2
3
4
5
6
7
8
9
1
1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @rikofebriyan ,

 

For this you need to do some advance steps on the Power Query:

  • Add an index column to your model

MFelix_0-1662024508194.png

  • Add a custom column with the following code:
if[#" OK"] = 1  then [#" OK"]* 100* [Index] else null

MFelix_1-1662024541834.png

 

  • Do a fill down on the custom column:

MFelix_2-1662024567491.pngMFelix_3-1662024577506.png

 

  • Do a group by the custom column with the aggregation of all the All rows:

MFelix_4-1662024625965.png

  • Add a new column with the following code:
Table.AddIndexColumn ( [RowCount], "RowNumber", 1 , 1)

MFelix_5-1662024668014.png

  • Expand the new column values:

MFelix_6-1662024693029.png

MFelix_7-1662024710720.png

  • Delete all the columns you don't need:

MFelix_8-1662024756909.png

 

Full code below:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMsBB4pfFr4Zyk4khqWWOglJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#" OK" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{" OK", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each if[#" OK"] = 1  then [#" OK"]* 100* [Index] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom",{"Custom"}),
    #"Grouped Rows" = Table.Group(#"Filled Down", {"Custom"}, {{"RowCount", each _, type table [#" OK"=nullable number, Index=number, Custom=number]}}),
    #"Added Custom1" = Table.AddColumn(#"Grouped Rows", "Custom.1", each Table.AddIndexColumn ( [RowCount], "RowNumber", 1 , 1)),
    #"Expanded Custom.1" = Table.ExpandTableColumn(#"Added Custom1", "Custom.1", {" OK", "Index", "RowNumber"}, {"OK", "Index", "RowNumber"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom.1",{"Custom", "RowCount", "Index"})
in
    #"Removed Columns"

 

 

 

 

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @rikofebriyan ,

 

For this you need to do some advance steps on the Power Query:

  • Add an index column to your model

MFelix_0-1662024508194.png

  • Add a custom column with the following code:
if[#" OK"] = 1  then [#" OK"]* 100* [Index] else null

MFelix_1-1662024541834.png

 

  • Do a fill down on the custom column:

MFelix_2-1662024567491.pngMFelix_3-1662024577506.png

 

  • Do a group by the custom column with the aggregation of all the All rows:

MFelix_4-1662024625965.png

  • Add a new column with the following code:
Table.AddIndexColumn ( [RowCount], "RowNumber", 1 , 1)

MFelix_5-1662024668014.png

  • Expand the new column values:

MFelix_6-1662024693029.png

MFelix_7-1662024710720.png

  • Delete all the columns you don't need:

MFelix_8-1662024756909.png

 

Full code below:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSK1YlWMsBB4pfFr4Zyk4khqWWOglJsLAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#" OK" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{" OK", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each if[#" OK"] = 1  then [#" OK"]* 100* [Index] else null),
    #"Filled Down" = Table.FillDown(#"Added Custom",{"Custom"}),
    #"Grouped Rows" = Table.Group(#"Filled Down", {"Custom"}, {{"RowCount", each _, type table [#" OK"=nullable number, Index=number, Custom=number]}}),
    #"Added Custom1" = Table.AddColumn(#"Grouped Rows", "Custom.1", each Table.AddIndexColumn ( [RowCount], "RowNumber", 1 , 1)),
    #"Expanded Custom.1" = Table.ExpandTableColumn(#"Added Custom1", "Custom.1", {" OK", "Index", "RowNumber"}, {"OK", "Index", "RowNumber"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom.1",{"Custom", "RowCount", "Index"})
in
    #"Removed Columns"

 

 

 

 

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português





Helpful resources

Announcements
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.

March Power BI Update Carousel

Power BI Community Update - March 2026

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