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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors