Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello guys,
I am trying to count every single ID where status is only green.
Based on screenshot the solution should be: 3 (ID:1 + ID:2 + ID:2) Every other ID can't be count in since there is one status = red.
Can anybody help me ?
Solved! Go to Solution.
If you want to count the Unique Ids where the status is only green you can use the following:
Green IDs =
VAR _green =
CALCULATETABLE (
VALUES ( 'Status table'[ID] ),
FILTER ( 'Status table', 'Status table'[Status] = "green" )
) //Returns a table of ID values whose status = "green"
VAR _NotGreen =
CALCULATETABLE (
VALUES ( 'Status table'[ID] ),
FILTER ( ALL ( 'Status table' ), 'Status table'[Status] <> "green" )
) //Returns a table of ID Values whose status is not/also not green
RETURN
COUNTROWS ( EXCEPT ( _green, _NotGreen ) )
//Except returns a table of IDs in which the ID values from the table returned by _NotGreen are excluded from the ID values returned by the _green table.
If, however, you want to count the rows for the IDs with only a green status you can use:
Green Id rows =
VAR _green =
CALCULATETABLE (
VALUES ( 'Status table'[ID] ),
FILTER ( 'Status table', 'Status table'[Status] = "green" )
)
VAR _NotGreen =
CALCULATETABLE (
VALUES ( 'Status table'[ID] ),
FILTER ( ALL ( 'Status table' ), 'Status table'[Status] <> "green" )
)
RETURN
COUNTROWS ( CALCULATETABLE ( 'Status table', EXCEPT ( _green, _NotGreen ) ) )
//The same as the previous calculation, but counts the ROWS OF THE WHOLE TABLE (not only IDs) for IDs with only a status of = "green"
Proud to be a Super User!
Paul on Linkedin.
For fun only, a showcase of powerful Excel worksheet formulas
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
If you want to count the Unique Ids where the status is only green you can use the following:
Green IDs =
VAR _green =
CALCULATETABLE (
VALUES ( 'Status table'[ID] ),
FILTER ( 'Status table', 'Status table'[Status] = "green" )
) //Returns a table of ID values whose status = "green"
VAR _NotGreen =
CALCULATETABLE (
VALUES ( 'Status table'[ID] ),
FILTER ( ALL ( 'Status table' ), 'Status table'[Status] <> "green" )
) //Returns a table of ID Values whose status is not/also not green
RETURN
COUNTROWS ( EXCEPT ( _green, _NotGreen ) )
//Except returns a table of IDs in which the ID values from the table returned by _NotGreen are excluded from the ID values returned by the _green table.
If, however, you want to count the rows for the IDs with only a green status you can use:
Green Id rows =
VAR _green =
CALCULATETABLE (
VALUES ( 'Status table'[ID] ),
FILTER ( 'Status table', 'Status table'[Status] = "green" )
)
VAR _NotGreen =
CALCULATETABLE (
VALUES ( 'Status table'[ID] ),
FILTER ( ALL ( 'Status table' ), 'Status table'[Status] <> "green" )
)
RETURN
COUNTROWS ( CALCULATETABLE ( 'Status table', EXCEPT ( _green, _NotGreen ) ) )
//The same as the previous calculation, but counts the ROWS OF THE WHOLE TABLE (not only IDs) for IDs with only a status of = "green"
Proud to be a Super User!
Paul on Linkedin.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 97 | |
| 71 | |
| 50 | |
| 47 | |
| 44 |