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
Anonymous
Not applicable

Count unique values based on condition

Hi Guys,

 

I have some order and production line data.  What I want to do is for each production line I want to count the number of occurance of that production line in the table only if there is one order number relating to that production line.

 

This is the sample data and below is the required answer.

 

So I want to create a table by Production line number with no of Orders.

 

Please help.

 

Link to PBI file
https://drive.google.com/file/d/1syX7jSgZHhEuhDYvBuIqAiLSm52GUR9u/view?usp=sharing

 

Answer.PNG

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

You can use a slicer for the Order.No, create a calculated table:

Table = DISTINCT('Data'[Production Line No.])

A measure to count:

Count = 
CALCULATE (
    COUNT ( Data[Order No.] ),
    FILTER (
        ALLSELECTED ( Data ),
        'Data'[Production Line No.] IN DISTINCT ( 'Table'[Production Line No.] )
    )
) + 0

vyingjl_0-1634885933983.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

7 REPLIES 7
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

You can use a slicer for the Order.No, create a calculated table:

Table = DISTINCT('Data'[Production Line No.])

A measure to count:

Count = 
CALCULATE (
    COUNT ( Data[Order No.] ),
    FILTER (
        ALLSELECTED ( Data ),
        'Data'[Production Line No.] IN DISTINCT ( 'Table'[Production Line No.] )
    )
) + 0

vyingjl_0-1634885933983.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

BeaBF
Super User
Super User

@Anonymous Hi! I can't open the file, Can you paste here the data table on which to calculate what you requested?

 

Thx,

B.

Anonymous
Not applicable

Order No.Production Line No.
Order1A
Order1B
Order1C
Order2A
Order3A
Order4C
Order4D
Order4E
Order5A
Order6C
Order7D
Order8E
Order8D

@Anonymous Here two calculated columns to obtain your result:

 

COUNTT = CALCULATE(COUNT(Tabella[Order No.]), ALLEXCEPT(Tabella,Tabella[Order No.]))
 
TOTAL_ORDERS = IF(CALCULATE(SUM(Tabella[COUNTT]), Tabella[COUNTT] = 1) = BLANK(), 0, CALCULATE(SUM(Tabella[COUNTT]), Tabella[COUNTT] = 1))
 
Hope that's what you wanted!
B.
Anonymous
Not applicable

@BeaBF Thank you for the response. But we can not do it in a calculated column as the result should dynamically change based on the filters applied.

Anonymous
Not applicable

@BeaBF 

here is the Data

 

Order No.Production Line No.

Order1A
Order1B
Order1C
Order2A
Order3A
Order4C
Order4D
Order4E
Order5A
Order6C
Order7D
Order8E
Order8D
Anonymous
Not applicable

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.