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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DebbieK61
New Member

Creating a measure which counts rows that satisfy two conditions

I have a table in Power BI showing orders and their shipping times.  One column is called Shipping Method and contains values like same-day, first class, standard etc. Other columns are 'Order Date' and 'Shipping Date'.

 

I have calculated the shipping time in days by creating a calculated column called "Shipping Time" and deducting the order date from the shipping date.  For Same Day shipping, then, the calculated value should be 0 as the shipping date should be the same as the order date.

 

I would like to create a measure that counts the number of rows where the following conditions are satisfied:  Shipping Method is "Same Day" AND Shipping Time is >0.   However, I can't see any obvious ways to do this and I'm not experienced enough in DAX without any help.

 

I can use the filters on my table to satisfy the above conditions, but I would like the measure to display the total count of same day "fails" and update when refreshed with new data.

 

Please could someone help me?

 

Thank you in advance.

Debbie

1 ACCEPTED SOLUTION
rsbin
Super User
Super User

@DebbieK61 ,

Please try something like this for your Measure:

SameDay_Late = CALCULATE( COUNT( YourTable[OrderID]),
                       FILTER( YourTable,
                               YourTable[ShippingMethod] = "Same Day" &&
                               YourTable[ShippingTime] > 0 ))

This assumes [OrderId] is numeric.  If it is text use COUNTA.

Hope this gets you where you need to go.

Regards,

View solution in original post

2 REPLIES 2
DebbieK61
New Member

That has worked perfectly!  Thank you very much.  🙂

rsbin
Super User
Super User

@DebbieK61 ,

Please try something like this for your Measure:

SameDay_Late = CALCULATE( COUNT( YourTable[OrderID]),
                       FILTER( YourTable,
                               YourTable[ShippingMethod] = "Same Day" &&
                               YourTable[ShippingTime] > 0 ))

This assumes [OrderId] is numeric.  If it is text use COUNTA.

Hope this gets you where you need to go.

Regards,

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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