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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Abdulrahman_78
New Member

Distinct Count

Hi,

 

I am a new power BI User. i have two data sets (Sales data by customer code by date and Customer Mapping) joint each other with Customer code Key. sample data sets are as under:

Sales Data Set:

Customer Code

Month

Sales

124011

September

1,547

140593

September

-1,014

411412

September

-280

Customer Mapping Set:

Customer Code

Merge Code

124011

140593

140593

140593

411412

411412

 

i want to calculate the distint counts of Merge codes based on +ve sales. have used the below measure

=CALCULATE(DISTINCTCOUNT('Customer Mapping'[Merge code]),'Sales Data[Sales]'>0)

it should give me the results as '1' but it is showing as '2'

results:

Merge Code

Sales

Distinct Count

140593

533

1

411412

-280

1

 

it should give a distint count for '411412' as zero but it shows a 1. Kindly advise what am missing here.

 

Regards,

Abdul Rahman

               

4 REPLIES 4
amitchandak
Super User
Super User

@Abdulrahman_78 , if the issue is not resolved with the above solution, create a new column in sales

 

Merge code = related('Customer Mapping'[Merge code])  and try with this new column same formula

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
themistoklis
Community Champion
Community Champion

@Abdulrahman_78 

 

Create the following measure:

Measure = CALCULATE(DISTINCTCOUNT(Table_2[Merge Code]),FILTER(Table_1, Table_1[Sales]>0))

 

OR

You can simply create a column that flags records where sales are greater than 0.

 

 

Column = IF(Table_1[Sales]>0,1,0)

 

 

 Then create a measure with the following formula:

Measure = CALCULATE(DISTINCTCOUNT(Table_2[Merge Code]),Table_1[Column]=1)

 

dedelman_clng
Community Champion
Community Champion

Hi @Abdulrahman_78  - 

 

I cannot replicate your issue using your data and code. Can you share a copy of your PBIX with sensitive data removed?

 

2020-10-23 10_52_58-scratch4 - Power BI Desktop.png

 

David

Check your relation as measure looks correct! I replicated your issue and fixed by applying the relation below.

 

azaher68_1-1603476096521.png

 

azaher68_2-1603476372987.png

 

 

 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.