Forum Discussion

Daniel_L's avatar
Daniel_L
Frequent Visitor
6 years ago
Solved

Verifying a two step invoice approval process

Hello community,   How would you solve this case where we need to verify whether a two step invoice approval process is legitimate or not?   I have two tables containing information about given a...
  • sturlaws's avatar
    6 years ago

    Hi Daniel_L 

    Will this strategy work for you?


    First create a new table with the distinct InvoiceIDs like this

    InvoiceID =
    DISTINCT (
        UNION ( VALUES ( 'Phase A'[InvoiceID_A] ); VALUES ( 'Phase B'[InvoiceID_B] ) )
    )

    Then create a new calculated column using this code

    Number of =
    VAR phaseA_approvers =
        CALCULATETABLE (
            VALUES ( 'Phase A'[UserID_A] );
            FILTER ( VALUES ( 'Phase A' ); 'Phase A'[InvoiceID_A] = InvoiceID[InvoiceID] )
        )
    VAR phaseB_approvers =
        CALCULATETABLE (
            VALUES ( 'Phase B'[UserID_B] );
            FILTER ( VALUES ( 'Phase B' ); 'Phase B'[InvoiceID_B] = InvoiceID[InvoiceID] )
        )
    VAR phaseB_approvers_not_approvers_phaseA =
        FILTER ( phaseB_approvers; NOT ( [UserID_B] IN phaseA_approvers ) )
    RETURN
        IF (
            COUNTROWS ( phaseB_approvers_not_approvers_phaseA ) > 0;
            TRUE ();
            FALSE ()
        )

    Cheers,
    Sturla


    If this post helps, then please consider Accepting it as the solution. Kudos are nice too.