Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

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 2
FreemanZ
Super User
Super User

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:

FreemanZ_0-1676599550253.png

 

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

ChaseG_0-1676648604882.png

 

table results

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

 

 

I hope this clarifies.

 

Thanks,

 

Chase

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.