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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Thimma_pbi
Helper I
Helper I

Row Number help in calculated column

Hi,

 

Wanted to have calcualted column based on the Value column >0 based on Date and Partial attributes and it should repeate every month for different partial as mentioned below.

 

any help

DtPartialValueRow starts
01-01-2025L100
01-01-2025L100
01-01-2025L111
01-02-2025L112
01-02-2025L103
01-02-2025L104
01-03-2025L105
01-03-2025L1306
01-03-2025L107
01-04-2025L1258
01-04-2025L109
01-04-2025L1010
01-01-2025L200
01-01-2025L200
01-01-2025L200
01-02-2025L200
01-02-2025L200
01-02-2025L200
01-03-2025L231
01-03-2025L262
01-03-2025L2193
01-04-2025L204
01-04-2025L205
01-04-2025L2206
1 ACCEPTED SOLUTION
DataNinja777
Super User
Super User

Hi @Thimma_pbi ,

 

To calculate a running row number in a calculated column based on Value > 0, grouped by Partial and maintaining the row sequence across time, you can use DAX like this:

Row starts =
VAR CurrentDate = [Dt]
VAR CurrentPartial = [Partial]
VAR CurrentIndex = [Index]
RETURN
IF (
    [Value] > 0,
    CALCULATE (
        COUNTROWS (
            FILTER (
                YourTable,
                [Partial] = CurrentPartial &&
                [Dt] <= CurrentDate &&
                [Value] > 0 &&
                [Index] <= CurrentIndex
            )
        )
    ),
    0
)

This assumes you already have a unique [Index] column that ensures each row has a deterministic order. The logic checks if the current row has Value > 0. If so, it counts all prior rows with the same Partial, date up to the current one, and with Value > 0. This count becomes the row number. If Value is zero, it returns 0. The row number continues to increment for each non-zero value across time, separately for each Partial.

 

Best regards,

View solution in original post

4 REPLIES 4
v-sdhruv
Community Support
Community Support

Hi @Thimma_pbi ,
Just wanted to check if you had the opportunity to review the suggestions provided?
If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You

v-sdhruv
Community Support
Community Support

Hi @Thimma_pbi ,
Just wanted to check if you had the opportunity to review the suggestions provided?
If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You

v-sdhruv
Community Support
Community Support

Hi @Thimma_pbi ,
Just wanted to check if you had the opportunity to review the suggestions provided?
If the response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.
Thank You

DataNinja777
Super User
Super User

Hi @Thimma_pbi ,

 

To calculate a running row number in a calculated column based on Value > 0, grouped by Partial and maintaining the row sequence across time, you can use DAX like this:

Row starts =
VAR CurrentDate = [Dt]
VAR CurrentPartial = [Partial]
VAR CurrentIndex = [Index]
RETURN
IF (
    [Value] > 0,
    CALCULATE (
        COUNTROWS (
            FILTER (
                YourTable,
                [Partial] = CurrentPartial &&
                [Dt] <= CurrentDate &&
                [Value] > 0 &&
                [Index] <= CurrentIndex
            )
        )
    ),
    0
)

This assumes you already have a unique [Index] column that ensures each row has a deterministic order. The logic checks if the current row has Value > 0. If so, it counts all prior rows with the same Partial, date up to the current one, and with Value > 0. This count becomes the row number. If Value is zero, it returns 0. The row number continues to increment for each non-zero value across time, separately for each Partial.

 

Best regards,

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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