The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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
Solved! Go to Solution.
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.
Regards
Amine Jerbi
If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook
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.
Did you use SUM instead?
Can you share your file?
Is your porblem solved?
Regards
Amine Jerbi
If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook
If all good please mark the thread as solved for the rest of the community.
Regards
Amine Jerbi
If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook
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.
Regards
Amine Jerbi
If I answered your question, please mark this thread as accepted
and you can follow me on
My Website, LinkedIn and Facebook
User | Count |
---|---|
65 | |
61 | |
60 | |
53 | |
30 |
User | Count |
---|---|
180 | |
88 | |
71 | |
48 | |
46 |