Forum Discussion
SUM values filtered by another column
Hello,
I have been using Power BI for some time but I now run into an issue I don't know how to solve yet.
So I have a table like this:
| Code | OH | NOH |
| 125 | 1 | 0 |
| 125 | 1 | 0 |
| 125 | 1 | 0 |
| 125 | 1 | 0 |
| 125 | 0 | 1 |
| 125 | 0 | 1 |
| 126 | 1 | 0 |
| 126 | 1 | 0 |
| 126 | 0 | 1 |
| 127 | 1 | 0 |
| 127 | 1 | 0 |
| 127 | 1 | 0 |
| 127 | 1 | 0 |
| 128 | 0 | 1 |
| 128 | 0 | 1 |
And I would like to count the OH 1's and NOH 1's per code. The end result would look like this:
| Code | OH | NOH |
| 125 | 4 | 2 |
| 126 | 2 | 1 |
| 127 | 4 | 0 |
| 128 | 0 | 2 |
I have tried several DAX functions and some standard options which Power BI has. Up until now, I was not able to get the result I would like to see.
Maybe someone can help me out with this issue.
Thanks in advance.
Regards,
Wilfred
Count OH=
Hi WLFRD
VAR _Code = SELECTEDVALUE(TABLE[CODE])
VAR _RESULT = CALCULATE(COUNT(TABLE[OH]), TABLE[CODE] = _Code)
RETURN
_RESULT
do the same for NOH
But i think you want to see the SUM and not the COUNT. if so replace Count by SUM.
4 Replies
- aj1973
Community Champion
If all good please mark the thread as solved for the rest of the community.
- WLFRD
Helper III
For some reason the provided possible solution didn't solve the problem. What I've done is, use the standard Count and Distinct Count option in Power BI.
- aj1973
Community Champion
Did you use SUM instead?
Can you share your file?
Is your porblem solved?