Forum Discussion

QwertyMartijn's avatar
QwertyMartijn
Helper II
3 years ago

Mismatch in status count

Hi guys,

 

I have the following situation:

 

I am working with complaints, where we have a main complaint, and this is devided into multipe (or 1) 'subcomplaints'. Each complaint has its own status, e.g. completed, ongoing, delayed, etc.

 

When the status of all subcomplaints is' completed', the main complaint also should have the status 'completed'. Now, i want to count the complaints where this isn't the case; so i want to count the cases where all subcomplaints have the status 'completed', but the main complaint still has another status.

 

(The main- and subcomplaints are grouped by a unique id that they all share).

 

 

7 Replies

  • NaveenGandhi's avatar
    NaveenGandhi
    Memorable Member

    Hello QwertyMartijn 

    Try the below Dax.

     

    Main_Complaint = CALCULATE(
        COUNTROWS('complaint'),
        FILTER(
            'complaint',
            'complaint'[TypeKlacht] = "Main Complaint" &&
            'complaint'[Status] <> "Completed" &&
            CALCULATE(
                COUNTROWS('complaint'),
                ALLEXCEPT('complaint', 'complaint'[ID]),
                'complaint'[TypeKlacht] = "Sub Complaint",
                'complaint'[Status] <> "Completed"
            ) = 0
        )
    )
     
    Dataset i used and result.

     

     

    Let me know if this helps.

     

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


     

     
    • QwertyMartijn's avatar
      QwertyMartijn
      Helper II

      Thanks for your quick reply. In the data you used, i dont think the correct count should be 1.

       

      For both ID's 938831 and 867645 all subcomplaints are completed, but the status of the main complaint is still 'delegated. Therefore, i would like the code to return 2 counts.

      • NaveenGandhi's avatar
        NaveenGandhi
        Memorable Member

        QwertyMartijn 

        Please see for ID 938831 , One of the sub complaint is delegated, I changed it so to do a test case. With that sub complaint being changed to completed, The count is 2 as you expect.