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

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

Reply
carlacun
Regular Visitor

How to Count all the DAX Measure Values that have a specific value?

Dear all,

I have this matrix in PowerBI - this were all taken from a measure calculation.

carlacun_0-1740555426347.png

Now, I want to count all the measure values per color (e.g. how many are green, amber, red) using DAX function too.
Result should be: Green = 5, Amber = 1, and Red = 3


I tried searching online for answers but I can't seem to find the correct expression/functions to use.
Any help and recommendation is highly appreciated. Thank you.

4 REPLIES 4
freginier
Super User
Super User

Hey there!

 

To count occurrences of each specific value (Green, Amber, Red) in your Power BI measure results using DAX, you can use the following approach:

Use the CALCULATE function along with COUNTROWS and FILTER to count the occurrences of each value.

Count_Green =
CALCULATE(
COUNTROWS(YourTable),
YourTable[YourColumn] = "Green"
)

Count_Red =
CALCULATE(
COUNTROWS(YourTable),
YourTable[YourColumn] = "Red"
)

Count_Amber =
CALCULATE(
COUNTROWS(YourTable),
YourTable[YourColumn] = "Amber"
)

 

Don't forget to replace YourTable with your actual table name and replace YourColumn with the actual column that contains "Green", "Red", and "Amber".

 

Hope this helps!

😁😁

Hi there. 

The values I want to count is actually not a column.
It is a result of a 'measure' already. These are all from different measure. 

Its like--
Measure Result 1 =  Green
Measure Result 2 = Red

Measure Result 3 = Green
Measure Result 4 = Amber
and so on.

Now I want to total how many of the results are green, amber, or red.
Any idea on this one?

Hey there!

 

Since these results are not stored in a single column but are generated by multiple measures, you can create a new DAX measure to count the occurrences of each value.

Create a Measure for Counting "Green"= Count_Green =
VAR MeasuresList =
{
[Measure1],
[Measure2],
[Measure3],
[Measure4],
[Measure5]
}
RETURN
COUNTX( FILTER( MeasuresList, [Value] = "Green" ), [Value] )

 

For red:

Count_Red =
VAR MeasuresList =
{
[Measure1],
[Measure2],
[Measure3],
[Measure4],
[Measure5]
}
RETURN
COUNTX( FILTER( MeasuresList, [Value] = "Red" ), [Value] )

 

so on...... 

- The MeasuresList variable stores the values returned by different measures.
- COUNTX is used to iterate over the list and count how many times each value appears.
- FILTER ensures that only occurrences of a specific value (e.g., "Green", "Red", "Amber") are counted.

 

Hope this helps!

😁😁

Hi,

Share the download link of the PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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
Top Kudoed Authors