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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
LvanLaar
Frequent Visitor

Count where count > 1 based on grouping

I have been asked to do an analysis on orders with multiple shipments/colli.

Below a screenshot of a matrix visual with order number. A count of tracking codes and a sum of colli.

 

I would like to count tracking codes where the previous count is bigger than one. grouped by order number.

So in the example below I would expect to see blank rows on the 1 rows. And 150 as a total in the matrix / card visuals.

 

count-sum.PNG

 

I think this would be something like this in SQL. But I'm not sure how to do this in DAX.

SELECT order_number,

      COUNT(track_and_trace)
WHERE COUNT(track_and_trace > 1

GROUP BY order_number

1 ACCEPTED SOLUTION
FreemanZ
Super User
Super User

hi @LvanLaar 

Try plot with the OrderNumber column and a measure like:

count of Track and Trace =

VAR _count = COUNTROWS(TableName)

RETURN

IF(_count=1, BLANK(), _count)

 

for the total card visual, try like:

1PlusCountTotal = 

VAR _table =

ADDCOLUMNS(

    VALUES(TableName[OrderNumber]),

    "Count",

  CALCULATE(COUNTROWS(TableName))

)

RETURN

COUNTROWS(

   FILTER(

       _table,

       [Count]>1

   )

)

View solution in original post

1 REPLY 1
FreemanZ
Super User
Super User

hi @LvanLaar 

Try plot with the OrderNumber column and a measure like:

count of Track and Trace =

VAR _count = COUNTROWS(TableName)

RETURN

IF(_count=1, BLANK(), _count)

 

for the total card visual, try like:

1PlusCountTotal = 

VAR _table =

ADDCOLUMNS(

    VALUES(TableName[OrderNumber]),

    "Count",

  CALCULATE(COUNTROWS(TableName))

)

RETURN

COUNTROWS(

   FILTER(

       _table,

       [Count]>1

   )

)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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