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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
WLFRD
Helper III
Helper III

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:

CodeOHNOH
12510
12510
12510
12510
12501
12501
12610
12610
12601
12710
12710
12710
12710
12801
12801

 

And I would like to count the OH 1's and NOH 1's per code. The end result would look like this:

CodeOHNOH
12542
12621
12740
12802

 

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

1 ACCEPTED SOLUTION
aj1973
Community Champion
Community Champion

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

View solution in original post

4 REPLIES 4
WLFRD
Helper III
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
Community Champion

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

aj1973
Community Champion
Community Champion

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

aj1973
Community Champion
Community Champion

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.