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
JajatiDev
Helper II
Helper II

DAX to count number of rows with multiple conditions

Hi

Here is my order table;

Order NoSO LinesShipping Condition
1000110Ship as available
1000120Ship as available
1200210Ship complete
1200220Ship complete
1300110Ship as available
1300120Ship as available
1300130Ship as available
1400110Ship as available

 

If the shipping condition is 'Ship as available' then each of the order lines is treated separately. While if the order has the shipping condition as 'Ship complete' then the order is treated as 1 and all order lines need to ship together. This means in the above table I have 7 order lines.

 

I need assistance with the measures;

1. that counts the number of order lines based on shipping conditions, and

2. the other that just gives me the sum total of the count of order lines

 

Thanks and Regards

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please try the below measures, and check the attached pbix file.

 

Count based on the condition measure: = 
VAR available_table =
    FILTER ( Data, Data[Shipping Condition] = "Ship as available" )
VAR complete_table =
    FILTER (
        SUMMARIZE ( Data, Data[Order No], Data[Shipping Condition] ),
        Data[Shipping Condition] = "Ship complete"
    )
RETURN
    COUNTROWS ( available_table ) + COUNTROWS ( complete_table )

 

Count measure: = 
COUNTROWS( Data )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
JajatiDev
Helper II
Helper II

Hi Jihwan_Kim,

Thank you. The DAX function shared is working as expected.

 

Regards,

Jajati Dev

Jihwan_Kim
Super User
Super User

Hi,

Please try the below measures, and check the attached pbix file.

 

Count based on the condition measure: = 
VAR available_table =
    FILTER ( Data, Data[Shipping Condition] = "Ship as available" )
VAR complete_table =
    FILTER (
        SUMMARIZE ( Data, Data[Order No], Data[Shipping Condition] ),
        Data[Shipping Condition] = "Ship complete"
    )
RETURN
    COUNTROWS ( available_table ) + COUNTROWS ( complete_table )

 

Count measure: = 
COUNTROWS( Data )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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.