Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Counting Rows using condition for more than one column

Hi I've the following data that tracks how many users completed their training. The system that tracks training checks everytime the user access the training material how much is completed. From t...
  • v-alq-msft's avatar
    6 years ago

    Hi, Anonymous 

     

    Based on your description, you may create two measures as below. The pbix file is attached in the end.

    CountCompleted = 
    var _training = SELECTEDVALUE('Table'[Training Title])
    var tab = 
    SUMMARIZE(
        'Table',
        'Table'[Training Title],
        "flag",
        var newtab =
            ADDCOLUMNS(
                DISTINCT('Table'[User Email]),
                "flag",
                IF(
                    CALCULATE(
                        MAX('Table'[% Complete]),
                        FILTER(
                            ALL('Table'),
                            'Table'[Training Title] = EARLIER('Table'[Training Title])&&
                            'Table'[User Email] = EARLIER('Table'[User Email])
                        )
                    )=1,
                    1,0
                )
            )
        return
            SUMX(
                newtab,
                [flag]
            )
    )
    
    return
    SUMX(
        tab,
        [flag]
    )
    
    CountNotCompleted = 
    var _training = SELECTEDVALUE('Table'[Training Title])
    var tab = 
    SUMMARIZE(
        'Table',
        'Table'[Training Title],
        "flag",
        var newtab =
            ADDCOLUMNS(
                DISTINCT('Table'[User Email]),
                "flag",
                IF(
                    CALCULATE(
                        MAX('Table'[% Complete]),
                        FILTER(
                            ALL('Table'),
                            'Table'[Training Title] = EARLIER('Table'[Training Title])&&
                            'Table'[User Email] = EARLIER('Table'[User Email])
                        )
                    )<1,
                    1,0
                )
            )
        return
            SUMX(
                newtab,
                [flag]
            )
    )
    
    return
    SUMX(
        tab,
        [flag]
    )

     

    Result:

     

    Best Regards

    Allan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.