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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
ihungko
Frequent Visitor

How to count based on another column

Hi community folks,

 

I am building a KPI dashboard, but kind of struggling to write the correct measure. Can you please kindly help? Thanks a lot!

 

My dataset is like this, I want to calculate certain opportunity # based on the KPI criteria. The criteria is as follow:

  • Calculate Won / Pending Opportunity #, for each opportunity, 1 credit for each unique KPI Product Group 
  • For example,
    • Opportunity X, there are 2 products in two different KPI Product Group, so it will get 2 credits for Pending;
    • Opportunity Y, there are 3 products, but only in 2 unique KPI Product Group, so it will also get 2 credits for Pending;
    • Opportunity Z, there are 4 products all in KPI Product Group B, so it will only get 1 credit for Won

 

Opportunity NameProduct NameStageKPI Product Group
Opportunity XProduct A1PendingA
Opportunity XProduct B1PendingB
Opportunity YProduct A1PendingA
Opportunity YProduct A2PendingA
Opportunity YProduct B1PendingB
Opportunity ZProduct B1WonB
Opportunity ZProduct B2WonB
Opportunity ZProduct B3WonB
Opportunity ZProduct B4WonB
3 REPLIES 3
Uzi2019
Super User
Super User

Hi @ihungko 
You can simply write DISTINCTCOUNT().
If you want to take count against only opportunity name.

Uzi2019_0-1699528242201.png

 

If this not what you are looking for then let me know the expected output like what other columns you are expecting and count value against it.

 

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Hi Uzi, thanks for your reply.

 

DISTINCTCOUNT was my first option, however, there is a sistuation when kpi product group has more than 2, for example like the table below:

 

The desired outcome would be 

Opportunity NameCredit
Opportunity X1
Opportunity Y1
Opportunity Z1
Opportunity AA2
TOTAL5

 

But if I use DISTINCTCOUNT on KPI Product Group, it will be 3 in total,

ihungko_0-1699529192120.png

 

 

 

 

Opportunity NameProduct NameStageKPI Product Group
Opportunity XProduct APendingA
Opportunity YProduct APendingA
Opportunity ZProduct APendingA
Opportunity AAProduct BPendingB
Opportunity AAProduct CPendingC

@Uzi2019 

 

I created a column concatenating Opportunity Name and KPI Product Group, and then use Distinctcount. It worked! 

 

But I am still wondering if there's more efficient / lighter way to do so.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors