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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Excel and Power BI Differ in Distinct Count Results

I have 686 rows in a table and only 286 of them are distinct. I've been able to correctly calculate the count of the total distinct values using a measure. I take the same calculation that I used in the distinct values measure and put it into a new measure (I'm not referencing the measure, I'm taking the actual formula) and then filter that for a specific value (let's call it FilterValue A), instead of returning 164 I'm getting 172. Furthermore, when I repeat that for FilterValue B, I get 108 rows when it should be 116.

I've included two variations of the measure involving FilterValueA and they both return the same results. Using a COUNTIF in Excel gives me the proper results (164 and 116 for FilterValueA and FilterValueB, respectively), but in DAX in Power BI I'm getting 172 and 108, respectively.

Am I doing something wrong here?

CALCULATE ( 
DISTINCTCOUNT ( SC[Number]
),
'Dim Approval Status'[Approval Status] = "A"
)
CALCULATE ( 
DISTINCTCOUNT ( SC[Number]
),
FILTER ( SC,
RELATED ( 'Dim Approval Status'[Approval Status] ) = "A"
)
)​
1 ACCEPTED SOLUTION
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

Measure will inact with other slicers, table visual, bar visual in the same page or other columns in the same table visual with this measure. You can use removefilters() to remove the column you do not want to filter by it.

 

You can try some code like the following:

CALCULATE ( 
    DISTINCTCOUNT ( SC[Number]),
    'Dim Approval Status'[Approval Status] = "A" ,
    REMOVERFILTER('Columns that do not want to be affected')
)

 

Best Regards

Community Support Team _ chenwu zhu

 

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

3 REPLIES 3
v-chenwuz-msft
Community Support
Community Support

Hi @Anonymous ,

 

Measure will inact with other slicers, table visual, bar visual in the same page or other columns in the same table visual with this measure. You can use removefilters() to remove the column you do not want to filter by it.

 

You can try some code like the following:

CALCULATE ( 
    DISTINCTCOUNT ( SC[Number]),
    'Dim Approval Status'[Approval Status] = "A" ,
    REMOVERFILTER('Columns that do not want to be affected')
)

 

Best Regards

Community Support Team _ chenwu zhu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous ,Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Try like

CALCULATE (
DISTINCTCOUNT ( SC[Number]
),
FILTER('Dim Approval Status', 'Dim Approval Status'[Approval Status] = "A" )
)

Anonymous
Not applicable

I tried your suggestion and it returned the same result. I'm trying to figure out how to share the sample data workbook and PBIX with you since I can't seem to share the OneDrive link because my organization doesn't let me select the "Anyone with this link" option.

Interestingly enough, when I tried the measures with just the SC[Number] and the Approval Status in the Sample Data, I found that the numbers were correct there.

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.