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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
mizaskun
Helper II
Helper II

Count measure by groups

Good morning,

 

Can anybody help me with this measure please?

 

We sent a questionaire to some people of the company. Each question have 3 categories to be answered. A, B and C. Each category must be answered with a number. There is also a status field in that table with which we see if each cateogry of each question was correctly answered.

mizaskun_2-1625642230404.png

I need to come up with 2 measures: OK and Warning.

 

OK should be the number of questions correctly answered, which means that the 3 categories are with an OK. In this example only the question 3 was correctly answered.

Warning should be the number of questions with one warning along its answers. Questions number 1 and 2 should be warnings.

 

Thea measures should be:

  • OK: 1
  • Warning: 2

Thank you so much! 

 

2 REPLIES 2
PaulOlding
Solution Sage
Solution Sage

What results do you want if someone sliced by Category?

Let's say there's a slicer on the page with just Category B selected.  Should question 2 now be in OK or Warning?

 

These measure would count it as Warning (thanks to the ALLEXCEPT function.  You could take that bit out and Q2 would now be OK in the scenario above).

OK Count =
VAR _QsWithCounts = 
ADDCOLUMNS(
    VALUES('Table'[Question]),
    "@AllCount", CALCULATE(COUNTROWS('Table'), ALLEXCEPT('Table', 'Table'[Question])),
    "@OKCount", CALCULATE(COUNTROWS('Table'), 'Table'[Status] = "OK", ALLEXCEPT('Table', 'Table'[Question]))
    )
VAR _Result = COUNTROWS(FILTER(_QsWithCounts, [@OKCount] = [@AllCount]))
RETURN 
    _Result
    
Warning Count =
VAR _QsWithCounts = 
ADDCOLUMNS(
    VALUES('Table'[Question]),
    "@AllCount", CALCULATE(COUNTROWS('Table'), ALLEXCEPT('Table', 'Table'[Question])),
    "@OKCount", CALCULATE(COUNTROWS('Table'), 'Table'[Status] = "OK", ALLEXCEPT('Table', 'Table'[Question]))
    )
VAR _Result = COUNTROWS(FILTER(_QsWithCounts, [@OKCount] <> [@AllCount]))
RETURN 
    _Result

Thank you! It should be warning. I will try it! As soon as I check it I will accept as a solution! 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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