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
wcho92
Frequent Visitor

Countif combination in Power BI

Hi,

 

I have a table that look likes this:

A

B

C

D

E

Customer_ID (text)

ComputerName

(text)

Productname

Number of cores

(whole number)

Number of services

(whole number)

101app1X23
101app1Y23
101app2X11
102app1X21

 

I would like to add a column, which in Excel would look like: countif($A$2:$A2,$A2). This will count the number of unique customer_id's from 1 to x.

I would also like to add a column that count both the customer_id and the computername, in Excel this would be countifs(customer_id:customer_id,computername:computername).

 

The reason why I need this columns, is because I would like to sum the number of cores and services. In PowerBI, I will get 4 core counts for customer 101 and computername app1, but instead, I need the number of 2, because this is not repeated. Also, I don't want to display the product name too. 

 

Does somebody know how to write this Excel syntax in Power BI?

 

Thanks in advance!

1 ACCEPTED SOLUTION
v-diye-msft
Community Support
Community Support

Hi @wcho92 

 

I would like to add a column, which in Excel would look like: countif($A$2:$A2,$A2). This will count the number of unique customer_id's from 1 to x.

Kindly let me know if you'd like to get the below results: If not please kindly disclose the expected results.

Measure = DISTINCTCOUNT('Table'[Customer_ID])

09.PNG

 

I would also like to add a column that count both the customer_id and the computername, in Excel this would be countifs(customer_id:customer_id,computername:computername).

Not quite understand this requirement, please kindly elaborate and disclose the expected results.

 

 

Community Support Team _ Dina Ye
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
v-diye-msft
Community Support
Community Support

Hi @wcho92 

 

I would like to add a column, which in Excel would look like: countif($A$2:$A2,$A2). This will count the number of unique customer_id's from 1 to x.

Kindly let me know if you'd like to get the below results: If not please kindly disclose the expected results.

Measure = DISTINCTCOUNT('Table'[Customer_ID])

09.PNG

 

I would also like to add a column that count both the customer_id and the computername, in Excel this would be countifs(customer_id:customer_id,computername:computername).

Not quite understand this requirement, please kindly elaborate and disclose the expected results.

 

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
BA_Pete
Super User
Super User

Hi @wcho92 

 

I think DISTINCTCOUNT might be what you are after.

This would not be used in a calculated column as it would just evaluate to 1 within each row context. However, as a measure, it will calculate the number of unique values within whatever filter context you throw at it.

 

For example, for the number of unique customer IDs you would write a measure as follows:

NoOfCustID =
DISTINCTCOUNT( [Customer_ID (text)] )

 

Hope this is what you're after.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




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.