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
Mactoff
Regular Visitor

Count of 2 or more based on groupings

Below I have a sample table of students in different subjects. I am trying to write a DAX function that will return the count of Students who are failing 2 or more subjects. In the below table, this would be student 1 and student 3, so ideally the DAX function would return a value of 2.

 

 

SubjectStudentPass_Fail
110
210
311
121
221
321
130
230
330


This is the function I tried to write, but I receive an error that says there are more than a million rows (dataset is quite large) when all I want is one nominal value. Appreciate any assitance!

Failing2Subjects =
COUNTROWS (
FILTER (
SUMMARIZE (
StudentTable,
StudentTable[Student],
StudentTable[Subject],
"Fails",
COUNTX (
FILTER ( StudentTable, StudentTable[Pass_Fail] = 0 ),
StudentTable[Pass_Fail]
)
),
[Fails] > 1
)
)



5 REPLIES 5
tamerj1
Super User
Super User

@Mactoff 

Please try one of the following 

Failing2Subjects =
COUNTROWS (
    FILTER (
        ADDCOLUMNS (
            SUMMARIZE (
                FILTER ( StudentTable, StudentTable[Pass_Fail] = 0 ),
                StudentTable[Student]
            ),
            "@NumOfFails", CALCULATE ( COUNTROWS ( StudentTable ) )
        ),
        [@NumOfFails] > 1
    )
)
Failing2Subjects =
SUMX (
    SUMMARIZE (
        FILTER ( StudentTable, StudentTable[Pass_Fail] = 0 ),
        StudentTable[Student]
    ),
    CALCULATE ( IF ( COUNTROWS ( StudentTable ) > 1, 1 ) )
)

Hello, thanks again for getting back!

The first one I get this error:

Mactoff_0-1662146805777.png


With the second one I get the 1,000,000 rows error again.

Starting to think this isn't possible with DAX. Really appreciate the assistance and ideas though!

tamerj1
Super User
Super User

Hi @Mactoff 

Please try

Failing2Subjects =
COUNTROWS (
    FILTER (
        SUMMARIZE (
            FILTER ( StudentTable, StudentTable[Pass_Fail] = 0 ),
            StudentTable[Student],
            "@NumOfFails", COUNTROWS ( StudentTable )
        ),
        [@NumOfFails] > 1
    )
)

Thanks for getting back! I still get the million rows error unfortunately. I should mention that there a lot of other columns in the table. The table I showed in my example is the table summarized down (the way I think it needed to be).

Mactoff_0-1662141337995.png

 

@Mactoff 

If you try a simple measure like CONTROWS ( StudentTable )

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!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.