Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

Flagging rows with collections values across multiple rows with duplicates

Hello,

 

When the: account number, visit date, and departments are the same in a transaction table, our practice management system is incorrectly flagging rows for exclusion with "Y/N".  

 

In the example below, the Y/N column should be reversed:

 

AccountVisit DateDeptIncludePaymentDue
12345A1/23/2023DiagnosticN280345
12345A1/23/2023DiagnosticY0345

 

 

What I need is an additional column that has a Corrected flag column that flags a "Y" for the row with a Payment and a "N" for the row w/o (see far right column below):

 

AccountVisit DateDeptIncludePaymentDueCorrected
12345A1/23/2023DiagnosticN280345Y
12345A1/23/2023DiagnosticY0345N

 

Since this scenario only occurs when the account/visit date/dept are the same down columns the solution should simply carry over the value in the include column when the criteria described above are not met.  When the value for the Include column are both N or both Y, I would need those values carried over in to the correct column as below:

 

AccountVisit DateDeptIncludePaymentDueCorrected
12345A1/23/2023DiagnosticN280345N
12345A1/23/2023DiagnosticN0345N
12345A1/31/2023DiagnosticY280345Y

Any help greatly appreciated!

 

Thank you!

2 Replies

  • hi Anonymous 

    not sure if i fully get you, try to add a column like:

    Column = 
    VAR _table =
    FILTER(
        SELECTCOLUMNS(
            TableName,
            "Account", TableName[Account],
            "Visit Date", TableName[Visit Date],
            "Dept", TableName[Dept]
        ),
        TableName[Account]=EARLIER(TableName[Account])
            &&TableName[Visit Date]=EARLIER(TableName[Visit Date])
            &&TableName[Dept]=EARLIER(TableName[Dept])
    )
    VAR condition1 = COUNTROWS(_table) 
    VAR condition2 =
    COUNTROWS(
        DISTINCT(
            FILTER(
                _table,
                TableName[Include]=EARLIER(TableName[Include])
            )
        )
    ) 
    RETURN
    SWITCH(
        TRUE(),
        condition1=2&&condition2=2&&TableName[Include]="N", "Y", 
        condition1=2&&condition2=2&&TableName[Include]="Y", "N", 
        [Include]
    )

     

    it worked like:

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      FreemanZ 

       

      I added this DAX which churned but I ended up maxing out my memory.  I'll keep trying, maybe on a different machine.

       

      I realized that in the last table example, misstated what the result should be, apologies. The second table example is the desired result:

      AccountVisit DateDeptIncludePaymentDueCorrected
      12345A1/23/2023DiagnosticN280345Y
      12345A1/23/2023DiagnosticY0345N

       

      When the criteria are not met, I just need the current [Include] value returned

       

      table results

      AccountVisit DateDeptIncludePaymentDueCorrected
      12345A1/23/2023DiagnosticN280345Y
      12345A1/23/2023DiagnosticY0345N
      12345A1/30/2023DiagnosticY2565Y
      23569B1/31/2023OtherY400Y

       

       

      I hope this clarifies.

       

      Thanks,

       

      Chase