Forum Discussion

Jatin77's avatar
Jatin77
Icon for Helper I rankHelper I
3 years ago
Solved

Multi-condition dax for 5 categories

Hello all! I have columns such as empid, name, test date, check date, subject, TR date. I want to write a dax for a calculated column which will return the 5 categories in a single column such as,...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Jatin77 ,

     Please refer to my pbix file to see if it helps you.

    Create columns.

    Column =
    VAR _TEST =
        MAXX (
            FILTER ( ALL ( 'Sheet2' ), 'Sheet2'[name] = EARLIER ( 'Sheet2'[name] ) ),
            'Sheet2'[test date]
        )
    VAR _CHACK =
        MAXX (
            FILTER ( ALL ( 'Sheet2' ), 'Sheet2'[name] = EARLIER ( 'Sheet2'[name] ) ),
            'Sheet2'[check date]
        )
    VAR _testpending =
        IF ( _CHACK = BLANK () && _TEST = BLANK (), "Test pending", BLANK () )
    VAR _1 =
        CALCULATE (
            COUNT ( Sheet2[test date] ),
            FILTER (
                ALL ( Sheet2 ),
                Sheet2[emp ID] = EARLIER ( Sheet2[emp ID] )
                    && Sheet2[test date] <> BLANK ()
            )
        )
    VAR _ckeckpending =
        IF ( _1 <> BLANK (), "Check pending", BLANK () )
    VAR _1a =
        CALCULATE (
            COUNT ( Sheet2[test date] ),
            FILTER (
                ALL ( Sheet2 ),
                Sheet2[emp ID] = EARLIER ( Sheet2[emp ID] )
                    && Sheet2[test date] <> BLANK ()
            )
        )
    VAR _Reviewpending =
        IF ( _1a >= 1 && Sheet2[check date] = BLANK (), "Review pending", BLANK () )
    VAR _noaction =
        IF (
            _ckeckpending = BLANK ()
                && Sheet2[REVIEW PENDING1] = BLANK ()
                && _testpending = BLANK ()
                && Sheet2[TR date] = BLANK (),
            "No Action",
            BLANK ()
        )
    VAR _studyrequired =
        IF (
            _ckeckpending = BLANK ()
                && Sheet2[REVIEW PENDING1] = BLANK ()
                && _testpending = BLANK ()
                && Sheet2[TR date] <> BLANK (),
            "Study required",
            BLANK ()
        )
    RETURN
        IF (
            _testpending <> BLANK (),
            _testpending,
            IF (
                _Reviewpending <> BLANK ()
                    || _ckeckpending <> BLANK (),
                Sheet2[REVIEW PENDING1] & _ckeckpending,
                IF (
                    _noaction <> BLANK (),
                    _noaction,
                    IF ( _studyrequired <> BLANK (), _studyrequired, BLANK () )
                )
            )
        )
    

     

     

    How to Get Your Question Answered Quickly 

     

    Please provide more details with your desired output and pbix file without privacy information (or some sample data) .

     

    Best Regards
    Community Support Team _ Polly

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