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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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