Forum Discussion

tgalla01's avatar
tgalla01
Frequent Visitor
3 years ago
Solved

Counting/Sequencing based on multiple columns within the same table

Hi everyone! I hope this is a quick one for somebody...   I have an "orders" table that I need to insert a new DAX column into. I prefer to avoid M if possible due to the table size. I need to coun...
  • v-zhangti's avatar
    3 years ago

    Hi, tgalla01 

     

    You can try the following methods.
    Column:

    OrderCount = 
    CALCULATE (
        COUNT ( 'Table'[Order] ),
        FILTER (
            'Table',
            [Order] <= EARLIER ( 'Table'[Order] )
                && [Customer_ID] = EARLIER ( 'Table'[Customer_ID] )
        )
    )
    RANK = 
    RANKX (
        FILTER ( 'Table', [Customer_ID] = EARLIER ( 'Table'[Customer_ID] ) ),
        [Order],
        ,
        ASC
    )

    Both methods will get the results you expect.

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.