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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Incremental Value Increase by Row based on True/False of other column

Hi Power BI Community!

 

As a new user, and I have reached a wall and am now seeking guidance from y'all.

 

Problem: I am trying to increment values (i.e. 1, 2, 3, etc.) for specific rows in Column B depending on True/False in Column A. If the value is False in Column A, I want the next True value to continue to follow the incremental increase. Please see the example of the output in Column B*** for your reference. Grateful for any help on this!

Column A          Column B***

True                       1

True                       2

False                   (blank)

True                       3

True                       4

False                    (blank)

False                    (blank)
True                       5

True                       6

 

 

 

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

I believe it is much easier to do this in Power Query by adding Index Columns

Please see the file attached with your data

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCikqTVWK1UFiuCXmFKMJYZHDqSoWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type logical}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),
    #"Sorted Rows" = Table.Sort(#"Added Index",{{"Column1", Order.Descending}}),
    #"Added Index1" = Table.AddIndexColumn(#"Sorted Rows", "Index.1", 1, 1),
    #"Sorted Rows1" = Table.Sort(#"Added Index1",{{"Index", Order.Ascending}}),
    #"Removed Columns" = Table.RemoveColumns(#"Sorted Rows1",{"Index"}),
    #"Added Custom" = Table.AddColumn(#"Removed Columns", "Custom", each if [Column1] =true then [Index.1] else null),
    #"Removed Columns1" = Table.RemoveColumns(#"Added Custom",{"Index.1"})
in
    #"Removed Columns1"

View solution in original post

3 REPLIES 3
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

I believe it is much easier to do this in Power Query by adding Index Columns

Please see the file attached with your data

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCikqTVWK1UFiuCXmFKMJYZHDqSoWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type logical}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),
    #"Sorted Rows" = Table.Sort(#"Added Index",{{"Column1", Order.Descending}}),
    #"Added Index1" = Table.AddIndexColumn(#"Sorted Rows", "Index.1", 1, 1),
    #"Sorted Rows1" = Table.Sort(#"Added Index1",{{"Index", Order.Ascending}}),
    #"Removed Columns" = Table.RemoveColumns(#"Sorted Rows1",{"Index"}),
    #"Added Custom" = Table.AddColumn(#"Removed Columns", "Custom", each if [Column1] =true then [Index.1] else null),
    #"Removed Columns1" = Table.RemoveColumns(#"Added Custom",{"Index.1"})
in
    #"Removed Columns1"
Anonymous
Not applicable

Thanks so much @Zubair_Muhammad  and @Anonymous  for your assistance.

 

Zubair's option looks great!

 

Many thanks for this - solved my problem. Looking forward to keep learning this.


Best

K

Anonymous
Not applicable

@Anonymous  - Do you want to order by anything, or is the counting random?

 

I created the following Calculated Table with DAX:

 

Rand True False = ADDCOLUMNS(GENERATESERIES(1,100,1),"Random Truth", IF(RAND()>.5,TRUE(),FALSE()))

Then, the following Calculated Column:

True Ranking = 
var truth_current_row = [Random Truth]
var rownum = [Value]
return 
COUNTROWS(
    FILTER(
        ALL('Rand True False'),
        [Value] <= rownum           //Count rows less than or equal to the current row.
        && [Random Truth] = TRUE() //Only count TRUE rows.
        && truth_current_row = TRUE() //Only allows TRUE rows to receive a value.
    )
)

 

 

Cheers!

Nathan

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Solution Authors