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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
flaviobdsti
Helper I
Helper I

Count grouped data

Hello guys! I need a little help.
I searched before posting, but didn't find anything that could help me...

I have the following data:

CodeProductAmount
11Apple1,000
23Apple1,250
34Apple1,321
19Apple1,439
11Apple1,250
11Apple1,300
19Apple1,100
19Apple1,986
34Apple1,324

 

Based on the above data, I created a metric to sum the AMOUNT column grouped by CODE and got the result below:

CodeProductAmount
11Apple3,550
23Apple1,250
34Apple2,645
19Apple4,525

 

Based on this result I need to display how many CODE I have. In the example above the answer would be four (4), however when I make a metric Power BI does not consider the grouping and returns nine (9) instead of four (4) CODE. Can anyone tell me where I'm going wrong?

I tried to use the functions DAX like Count with distinct and Group by, but without success!

I appreciate who can help me!

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your desired outcome looks like, but please try to write below measure and put it into the card visualization.

 

Distinct count measure: =
COUNTROWS ( VALUES ( 'Tablename'[Code] ) )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure how your desired outcome looks like, but please try to write below measure and put it into the card visualization.

 

Distinct count measure: =
COUNTROWS ( VALUES ( 'Tablename'[Code] ) )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thank you very much! It worked!

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.