Forum Discussion

slhangen's avatar
slhangen
Icon for Helper II rankHelper II
5 years ago
Solved

Need count with multiple filters

I have created and Append table and need to get some calculations from it.

Table is called Append1 and looks like following:

TITLESTUDENT LAST NAMESTUDENT FIRST NAMEDESIGNATIONCOURSETEACHERSEMESTER GRADESEMESTER
999999ADAMSHENRY ADV PHY EDMAHRINGASEM 1
999999ADAMSHENRY DRAWING IBEINTUMFSEM 1
999999ADAMSHENRY DRIVER ED CLASSSTEPHENSBSEM 1
999999ADAMSHENRY INTR TECH & ENGRICEFSEM 1
999999ADAMSHENRY KEYBOARD FORMATQUILTYASEM 1
999999ADAMSHENRYCOREENGLISH IIPAINTERASEM 1
999999ADAMSHENRYESSAGEOMETRYRENOBSEM 1
999999ADAMSHENRYESSAPHYS SCIENCEFOGLIANOFSEM 1
222222ADAMSJOHN APPLIED MANUFACRICEASEM 1
222222ADAMSJOHN ARMY JROTC IIIWilliamsDSEM 1
222222ADAMSJOHN CAREER PLANHUBERTFSEM 1
222222ADAMSJOHNCOREAM GOVERNMENTPHILLIPSDSEM 1
222222ADAMSJOHNCOREAP ENGLISH LITRHOADESDSEM 1
222222ADAMSJOHNCOREECONOMICSQUILTYFSEM 2
333333AGUILERACHRISTINA ARMY JROTC IIIWilliamsCSEM 1
333333AGUILERACHRISTINA DRIVER ED CLASSSTEPHENSFSEM 1
333333AGUILERACHRISTINA ELL TUTORIALHINRICHSENFSEM 1
333333AGUILERACHRISTINA ESL IIBAILEYCSEM 1
333333AGUILERACHRISTINA SPAN HRT SPK IIHINRICHSENFSEM 1
333333AGUILERACHRISTINACOREUS HISTORYBAILEYCSEM 1
333333AGUILERACHRISTINAESSABIOLOGYCMCKENZIEBSEM 1
333333AGUILERACHRISTINAESSAGEOMETRYSZECHOWYCZFSEM 1

 

Need some DAX give me the following:

TITLESTUDENT LAST NAMESTUDENT FIRST NAMECOURSE FAILURESSEMESTER GRADESEMESTER
999999ADAMSHENRY3FSEM 1

 

Was thinking I could replicate this for SEM 2 in another table/measure.

 

Thx, Community!

  • Take a look at the following slhangen - just one measure I think is all you need:

    Course Failures = 
    COUNTX(
        FILTER(
            'Table',
            'Table'[SEMESTER GRADE] = "F"
        ),
        'Table'[SEMESTER GRADE]
    )

    Simply add the fields I have added to a Table visual, then add the Course Failures measure I created. It will calculate the correct numbers per semester.

    If that is not what you need, could you be more specific in the output you require and the logic to get there?

10 Replies

  • edhans's avatar
    edhans
    Icon for Community Champion rankCommunity Champion

    Take a look at the following slhangen - just one measure I think is all you need:

    Course Failures = 
    COUNTX(
        FILTER(
            'Table',
            'Table'[SEMESTER GRADE] = "F"
        ),
        'Table'[SEMESTER GRADE]
    )

    Simply add the fields I have added to a Table visual, then add the Course Failures measure I created. It will calculate the correct numbers per semester.

    If that is not what you need, could you be more specific in the output you require and the logic to get there?

    • slhangen's avatar
      slhangen
      Icon for Helper II rankHelper II

      This is amazing Ed, but I really need the following:

       

      TITLE      STUDENT LAST NAME      STUDENT FIRST NAME     COURSE FAILURES- SEM 1     COURSE FAILURES- SEM 2

       

      Can you help with this?  I would be forever on your debt, lol.

      • edhans's avatar
        edhans
        Icon for Community Champion rankCommunity Champion

        Sure, that will require two measures:

         

        Course Failures Semester 1 = 
        COUNTX(
            FILTER(
                'Table',
                'Table'[SEMESTER GRADE] = "F"
                    && 'Table'[SEMESTER] = "SEM 1"
            ),
            'Table'[SEMESTER GRADE]
        )

         

        and 

         

        Course Failures Semester 2 = 
        COUNTX(
            FILTER(
                'Table',
                'Table'[SEMESTER GRADE] = "F"
                    && 'Table'[SEMESTER] = "SEM 2"
            ),
            'Table'[SEMESTER GRADE]
        )

         

        Then I got rid of the Semester field in the visual and added both of these measures, and I get this:

        Alternatively, you can keep my original measure and use a MATRIX visual instead:

        It has these fields:

        You need to do a few things to the matrix to make it work and look like I have it:

        • Turn off stepped layout
        • Turn off row subtotals
        • Drill all the way down on the matrix using the single-to-double down arrow when you hover over the matrix.
          •  

        • I like the matrix solution better because it is 1 measure and the semesters would dynamically expand (summer summester for example) without having to write a 3rd semester measure.

        But that is the cool thing about Power BI slhangen - different ways to do the same thing. Take your pick!

         

         

  • edhans's avatar
    edhans
    Icon for Community Champion rankCommunity Champion

    Glad I was able to help slhangen - hope your project moves forward smoothly.