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

Shape the future of the Fabric Community! Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions. Take survey.

Reply
Anonymous
Not applicable

Count if and Sum by Group

Hello there,

I want to do something that seems simple, but I just can't figure it out. 

I want to count instances where a value is >= 90% and also separately count values that are below that

I have this data in the table: Production:

PlantMaterialProduction%
Plant1Material10.8034
Plant2Material20.9532
Plant1Material30.9804
Plant1Material41.0000
Plant2Material50.7532

 

If Production% is >= 90% (.9000) then count it as 1 pass.  If < 90% then count as 1 fail, and sum and display both in a Matrix like this:

 

PlantPass >=90Fail <90
Plant 121
Plant 211

 

Thanks.

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

You can create the following 2 measures for calculating the counts of instances( >= 90%) and instances( < 90%) separately, and put them on Values tab of matrix:

Pass =

CALCULATE (

    COUNTROWS ( 'Production' ),

    FILTER ( 'Production', 'Production'[Production%] >= 0.9 )

)

 

Fail =

CALCULATE (

    COUNTROWS ( 'Production' ),

    FILTER ( 'Production', 'Production'[Production%] < 0.9 )

)

sum by group.JPG

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

You can create the following 2 measures for calculating the counts of instances( >= 90%) and instances( < 90%) separately, and put them on Values tab of matrix:

Pass =

CALCULATE (

    COUNTROWS ( 'Production' ),

    FILTER ( 'Production', 'Production'[Production%] >= 0.9 )

)

 

Fail =

CALCULATE (

    COUNTROWS ( 'Production' ),

    FILTER ( 'Production', 'Production'[Production%] < 0.9 )

)

sum by group.JPG

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
kentyler
Solution Sage
Solution Sage

Usually people prefer measures over calculated columns, but this might be a case where a calculated column would come in handy.

calccolumn.PNG

I'm a personal Power Bi Trainer I learn something every time I answer a question

The Golden Rules for Power BI

  1. Use a Calendar table. A custom Date tables is preferable to using the automatic date/time handling capabilities of Power BI. https://www.youtube.com/watch?v=FxiAYGbCfAQ
  2. Build your data model as a Star Schema. Creating a star schema in Power BI is the best practice to improve performance and more importantly, to ensure accurate results! https://www.youtube.com/watch?v=1Kilya6aUQw
  3. Use a small set up sample data when developing. When building your measures and calculated columns always use a small amount of sample data so that it will be easier to confirm that you are getting the right numbers.
  4. Store all your intermediate calculations in VARs when you’re writing measures. You can return these intermediate VARs instead of your final result  to check on your steps along the way.

 





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.