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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors