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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Earl40
Helper I
Helper I

Distinct count based on conditions for other columns

Hello,

Im trying to count only the distinct values in a column called "Order ID" but only when certain criteria is present in other columns, 

 the criteria: count distincy values in Order ID column , only where system column is "OCI" and the type column is "Notification" and origina column is "AB" and the date colum (which shows month and year e.g October 2023) is February 2024. 

 

Any help would be greatly apreciated

2 ACCEPTED SOLUTIONS
olgad
Super User
Super User

DistinctOrderCount =
CALCULATE( COUNTROWS( VALUES('YourTable'[Order ID]) ),
'YourTable'[system] = "OCI",
'YourTable'[type] = "Notification",
'YourTable'[original] = "AB",
FORMAT('YourTable'[date_column], "YYYYMM") = "202402" )


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

View solution in original post

Anonymous
Not applicable

Hi @Earl40 ,

First of all, many thanks to @olgad  for your very quick and effective replies, I'll provide a different dax formula below for your reference.

DistinctCountConditional = 
CALCULATE(
    DISTINCTCOUNT('YourTableName'[Order ID]),
    'YourTableName'[system] = "OCI",
    'YourTableName'[type] = "Notification",
    'YourTableName'[origina] = "AB",
    FORMAT('YourTableName'[date], "MMMM YYYY") = "February 2024"
)

 

Please replace `'YourTableName'` with the actual name of your table.

 

Best regards,
Community Support Team_Binbin Yu
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

2 REPLIES 2
Anonymous
Not applicable

Hi @Earl40 ,

First of all, many thanks to @olgad  for your very quick and effective replies, I'll provide a different dax formula below for your reference.

DistinctCountConditional = 
CALCULATE(
    DISTINCTCOUNT('YourTableName'[Order ID]),
    'YourTableName'[system] = "OCI",
    'YourTableName'[type] = "Notification",
    'YourTableName'[origina] = "AB",
    FORMAT('YourTableName'[date], "MMMM YYYY") = "February 2024"
)

 

Please replace `'YourTableName'` with the actual name of your table.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

olgad
Super User
Super User

DistinctOrderCount =
CALCULATE( COUNTROWS( VALUES('YourTable'[Order ID]) ),
'YourTable'[system] = "OCI",
'YourTable'[type] = "Notification",
'YourTable'[original] = "AB",
FORMAT('YourTable'[date_column], "YYYYMM") = "202402" )


DID I ANSWER YOUR QUESTION? PLEASE MARK MY POST AS A SOLUTION! APPRECIATE YOUR KUDO/LIKE!
PROUD TO BE A SUPER USER!
Best Stories, Interesting Cases: PowerBI Storytime Newsletter
Linkedin Profile: Linkedin
YouTube Channel: PowerBI Storytime

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.