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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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