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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
kheira
Frequent Visitor

count without duplicates

hi 
i have two columns and i want to count how many product id in statmeent without duplicates production with the same id 
how i can do that with dax? image.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hello @kheira 
Count I want =
VAR StatementCount =
CALCULATE(
DISTINCTCOUNT('Table'[Satement ID])
)
VAR ProductCount =
CALCULATE(
COUNT('Table'[Product ID]),
ALL('Table'[Product ID])
)
RETURN
ProductCount - StatementCount
Capture.PNG

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hello @kheira 
Count I want =
VAR StatementCount =
CALCULATE(
DISTINCTCOUNT('Table'[Satement ID])
)
VAR ProductCount =
CALCULATE(
COUNT('Table'[Product ID]),
ALL('Table'[Product ID])
)
RETURN
ProductCount - StatementCount
Capture.PNG

thank you 😍

AlB
Super User
Super User

@kheira 

I guess you mean a 3 for the statement id 6

New column =
CALCULATE (
    DISTINCTCOUNT ( Table1[Product ID] ),
    ALLEXCEPT ( Table1, Table1[statement id] )
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

AlB
Super User
Super User

Hi @kheira 

1. Place Statement ID in a table visual

2. Place this measure in the visual

Measure =
DISTINCTCOUNT( Table1[Product ID])

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

kheira
Frequent Visitor

thank u 
but i want to add new coulmn dax to get the result .. i tried to do dax :

CALCULATE( COUNT('Table'[product id]), ALLEXCEPT('Table','Table'[product id])) - CALCULATE( DISTINCTCOUNT('Table'[statment id]), ALLEXCEPT('Table','Table'[statment id]))
but i want  the count  is 4 in "statment id "=6kheira_0-1610531371145.png

 

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.

Top Solution Authors