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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
syasmin25
Helper V
Helper V

Counts ID if id has values in more than 1 value in a different column

Hello,

I am trying to count ID’s that have a “D or F” in more than 1 or more subjects.

I have the following table,

 

IDPeriodGradeBldg#Subject

101S1A2356English
102S1D2356Math
102S1F2356Science
102S1F2356English
103S1B2356Science
103S2A2154English
104S1B2356English
104S2B2154Science
105S1C2356Math
105S2B2154English
105S2F2154Science
106S2A2154Science

 

& I have created the following visual. I am trying to create a column/measure that counts the ID if they have have a “D or F” in English and Math or even English, Math and Science. I am also trying to create a column that holds " English and Math" & “English, Math & Science” as values. I am trying to insert a table that would hold those values underneath the table in the image below and calculate their f%. I tried creating conditional columns to separate subjects and then doing an unpivot but realized that it was creating duplicate ID’s and also each ID has subject in a different row. Any help would be appreciated.

 
 
 

syasmin25_0-1610055407430.png

 

 

 

I can't seem to attach the file here.

3 REPLIES 3
mahoneypat
Microsoft Employee
Microsoft Employee

Please try this measure expression, replacing "Grades" for your actual table name.

 

Students with 1+ D or F =
COUNTROWS (
    FILTER (
        VALUES ( Grades[ID] ),
        CALCULATE (
            COUNTROWS ( Grades ),
            Grades[Grade]
                IN {
                "D",
                "F"
            }
        ) > 0
    )
)

 

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


I apologize for the late response, the "IN" statement here seems to count if they have failed either D or F, I am trying to count when there is both D and F.

Thank you for your help. Unfortunately, I am actually wanting the table to look somewhat like the image below. This is where I am struggling with counts as unpivoting them creates duplicates.

syasmin25_0-1610059946957.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.

Top Kudoed Authors