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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
syasmin25
Helper V
Helper V

Counts of 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-1610055550558.png

 

 

 

I can't seem to attach the file here.

 

9 REPLIES 9
littlemojopuppy
Community Champion
Community Champion

Hi @syasmin25 

 

Try this...

 

Failing Grade Count = 
    VAR StudentTermSummary =
        SUMMARIZE(
            ALLSELECTED(Grades),
            Grades[ID],
            Grades[Period],
            "FailingGrades",
            CALCULATE(
                COUNTROWS(Grades),
                Grades[Grade] IN {"D", "F"}
            )
        )
    RETURN

    CALCULATE(
        DISTINCTCOUNT(Grades[ID]),
        FILTER(
            StudentTermSummary,
            [FailingGrades] > 0
        ),
        VALUES(Grades[Period])
    )

 

littlemojopuppy_0-1610057716616.png

 

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_2-1610060038523.png

 

 

@syasmin25  how about this?

Failing Grade Count = 
    VAR StudentTermSummary =
        SUMMARIZE(
            ALLSELECTED(Grades),
            Grades[ID],
            Grades[Subject],
            "FailingGrades",
            CALCULATE(
                COUNTROWS(Grades),
                Grades[Grade] IN {"D", "F"}
            )
        )
    RETURN

    CALCULATE(
        DISTINCTCOUNT(Grades[ID]),
        FILTER(
            StudentTermSummary,
            [FailingGrades] > 0
        ),
        VALUES(Grades[Subject])
    )

 

littlemojopuppy_0-1610060635518.png

 

Hello, 

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 again, this seems to make a lot of sense. However, I would like to make combination as the image below, how would I create a table like that to do the counts using the the raw data posted above in the question?

syasmin25_0-1610061147604.png

 

@syasmin25 , for this one you might have create two meaures with filters, with formula suggested in last post and then use those measures in matrix, and use Option "Show on Row"

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hey @amitchandak dd you notice where someone else offered a solution???  😐

@littlemojopuppy , Again no overlap with your Answer. I just suggested display way.  Check - "with formula suggested in last post"

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

🙄

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.