Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
97 | |
85 | |
70 | |
61 |
User | Count |
---|---|
151 | |
120 | |
103 | |
87 | |
68 |