Forum Discussion

afaherty's avatar
afaherty
Helper V
2 years ago
Solved

Insert Column Help

Greetings all, I would like to insert a column to categorize students as "pass" or "fail."  But the key here is that they can take their test in any subject multiple times.  So if they've failed any...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, afaherty 

    Based on your description and the data information you provided, I used the following sample data:

    I created a calculated column using the following DAX expression:

    Column = 
    VAR _table = FILTER(ALL('Table'),'Table'[StudentID]=EARLIER('Table'[StudentID]))
    RETURN IF("pass" IN SELECTCOLUMNS(_table,"aa",'Table'[PassFail]),"Pass","Fail")

    Here are the results:

    I've uploaded the PBIX file I used this time below.

     

     

    How to Get Your Question Answered Quickly

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

    Best Regards

    Jianpeng Li

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

     

     

  • some_bih's avatar
    2 years ago

    Hi afaherty one possible solution is to create measure Measure_Fail and create new column, like Measure_Catagory with reference to that measure (create measure first) and you should get output

    Measure_Catagory = [Measure_Fail]

     

    Measure_Fail =
    VAR __check_fail_or_pass =
    CALCULATE(
        DISTINCTCOUNT(Table_1[PassFail]),
        Table_1[PassFail] = "Pass",
        ALLEXCEPT(
            Table_1,
            Table_1[StudentID]
        )
    )

    RETURN
        IF(
            __check_fail_or_pass = 1,
            "Pass",
            "Fail"
        )
     
    Output