Forum Discussion

NSBS's avatar
NSBS
Helper I
3 years ago
Solved

Counting Rows with Conditions in Measure

Hi PowerBI Community,   Need some help in creating a DAX measure code for below case. Considering below attempt # and its status for each person, and the Overall Status will be consided as "Pass...
  • v-jianboli-msft's avatar
    3 years ago

    Hi NSBS ,

     

    Please try:

    Count Passed = 
    var _a = ADDCOLUMNS(ALL('Table'),"Overall", IF("Passed" in SELECTCOLUMNS(FILTER('Table',[Name]=EARLIER('Table'[Name])&&[Attempt]<=3),"Attempt status",[Attempt Status]),
    "Passed","Failed"))
    return CALCULATE(DISTINCTCOUNT('Table'[Name]),FILTER(_a,[Overall]="Passed"))

    Final output:

     

    Best Regards,

    Jianbo Li

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