cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Running count with multiple conditions

Hi,

 

Below is a simple example of the calculated column I am trying to create.

Last row showing the running count based on product and customer being the same. Order Qty is not relevant.

 

ProductCustomerOrder QtyCount
A12351
A12352
A12353
B45651
C45651
C45652
 

Thanks,

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User II
Super User II

Hi @rhys1987 

You need to first add an index column to the table to indicate precedence. Otherwise there is no way to differentiate those rows in your count. You can do that easily in PQ. Then your calculated column:

 

Col =
CALCULATE (
    COUNT ( Table1[Product] ),
    ALLEXCEPT ( Table1, Table1[Product], Table1[Customer] ),
    Table1[Index] <= EARLIER ( Table1[Index] )
)

 

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

View solution in original post

1 REPLY 1
Highlighted
Super User II
Super User II

Hi @rhys1987 

You need to first add an index column to the table to indicate precedence. Otherwise there is no way to differentiate those rows in your count. You can do that easily in PQ. Then your calculated column:

 

Col =
CALCULATE (
    COUNT ( Table1[Product] ),
    ALLEXCEPT ( Table1, Table1[Product], Table1[Customer] ),
    Table1[Index] <= EARLIER ( Table1[Index] )
)

 

 

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors