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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
awitt
Helper III
Helper III

Filter Table Using Sum

I'm looking to create a measure that counts the number of single line orders in a table. For example, this table would yeild a result of 2 (or list the two order numbers out) since there were only two unique order #'s that only had a single item on the order. 

 

Question.PNG

 

I had written this but it clearly isn't working...

 

Single Line Orders = CALCULATE(
             DISTINCTCOUNT(Order #),
                Filter('Table'),
                   Sum('Table'[Item Qty) = 1)
)

2 REPLIES 2
v-xicai
Community Support
Community Support

Hi awitt,

 

For your DAX function, there are two expression errors like picture below, while it can't return the correct result after correct the DAX.

 2.png

To work the issue, you can follow steps below.

 

Firstly, you can create intermediate table Count_Table to count distinct Order.

 

3.jpg

 

 

 

 

 

 

 

 

 

 

 

 

4.png

 

 

 

 

Then, create measure named Single Line Orders to count the unique order.

 

Single Line Orders = CALCULATE(COUNT('Table'[Order #]),Count_Table[Count]=1)

 

Finally, return the result showing picture below.

 

5.png

 

 

 

 

 

 

 

 

 

Here is my test pbix file link: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EUhaNajioVZGnIwAN2...

 

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Zubair_Muhammad
Community Champion
Community Champion

@awitt 

 

try  following Measure

 

Measure =
COUNTROWS (
    FILTER (
        ALL ( TableName[Order#] ),
        CALCULATE ( COUNT ( TableName[Order#] ) ) = 1
    )
)

Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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