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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
space83
Helper IV
Helper IV

add running no column via direct query

Below is example of my report.

 

add-running-no.png

How can I create new virtual column and display running no of the record?

 

it will auto count.

 

Please dont tell me using 'add column > index' since it will not work.

Index is for data Import. 

I am using Direct Query.

12 REPLIES 12
space83
Helper IV
Helper IV

Hi @wdx223_Daniel ,

Now it works. I am using below formula. Thanks for your help.

No = VAR _order =
    MAX ( OrderIntake[Order No] )
VAR _date =
    MAX ( OrderIntake[Status Date] )
RETURN
    COUNTROWS (
        FILTER (
            SUMMARIZE ( ALLSELECTED ( OrderIntake ), OrderIntake[Order No], OrderIntake[Status Date] ),
            ISONORAFTER ( OrderIntake[Order No], _order, , OrderIntake[Status Date], _date, ASC )
        )
    )

 

space83
Helper IV
Helper IV

Hi @wdx223_Daniel,

Thanks for your help but I think that is not the solution.

Once I do filtering, the running no will messy as u can see below:

filter-date-count.jpg

 

@space83 dose it work to change ALL to ALLSELECTED?

Hi @wdx223_Daniel ,

After I look in deep, my data is not correct. For duplicate Order No and Status Date it will show once. Thus create a running no will not solve the problem.

 

I just use the syntax below and I got result i want which is total of order for 1 interval date.

 

Total Order No = COUNT(OrderIntake[Order No])

 

result.jpg

 

@space83 DAX can not know which one is first if all the columns is identical.

space83
Helper IV
Helper IV

Hi @wdx223_Daniel,

I received output as below which is got duplicate running no. I think the DAX syntax need to edit some where.

 

duplicate-running-no.jpg

@space83 try this

=
VAR _order =
    MAX ( Table[Order No] )
VAR _date =
    MAX ( Table[Status Date] )
RETURN
    COUNTROWS (
        FILTER (
            SUMMARIZE ( ALL ( Table ), Table[Order No], Table[Status Date] ),
            ISONORAFTER ( Table[Order No], _order, DESC, Table[Status Date], _date, DESC )
        )
    )

Hi @wdx223_Daniel ,

I do not understand, somehow the count is not start with 1. U can refer pic as below:

running_No.jpg

@space83 this depends on what order your date is, in your snapshot, order no and date is sorted descending. so you need change code to 

=
VAR _order =
    MAX ( Table[Order No] )
VAR _date =
    MAX ( Table[Status Date] )
RETURN
    COUNTROWS (
        FILTER (
            SUMMARIZE ( ALL ( Table ), Table[Order No], Table[Status Date] ),
            ISONORAFTER ( Table[Order No], _order, , Table[Status Date], _date,  )
        )
    )
wdx223_Daniel
Super User
Super User

=VAR _order=MAX(Table[Order No]) VAR _date=MAX(Table[Status Date]) RETURN COUNTROWS(FILTER(SUMMARISE(ALL(Table),Table[Order No],Table[Status Date]),Table[Order No]<_order&&Table[Status Date]<_date))+1

Hi @wdx223_Daniel,

What is this? where should I put this snippets? New column, New measure?

@space83  it's a measure, create a new measure with that code, then drag it into the visual.

Helpful resources

Announcements
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 Kudoed Authors