Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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:
Account | Visit Date | Dept | Include | Payment | Due |
12345A | 1/23/2023 | Diagnostic | N | 280 | 345 |
12345A | 1/23/2023 | Diagnostic | Y | 0 | 345 |
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):
Account | Visit Date | Dept | Include | Payment | Due | Corrected |
12345A | 1/23/2023 | Diagnostic | N | 280 | 345 | Y |
12345A | 1/23/2023 | Diagnostic | Y | 0 | 345 | N |
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:
Account | Visit Date | Dept | Include | Payment | Due | Corrected |
12345A | 1/23/2023 | Diagnostic | N | 280 | 345 | N |
12345A | 1/23/2023 | Diagnostic | N | 0 | 345 | N |
12345A | 1/31/2023 | Diagnostic | Y | 280 | 345 | Y |
Any help greatly appreciated!
Thank you!
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:
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:
Account | Visit Date | Dept | Include | Payment | Due | Corrected |
12345A | 1/23/2023 | Diagnostic | N | 280 | 345 | Y |
12345A | 1/23/2023 | Diagnostic | Y | 0 | 345 | N |
When the criteria are not met, I just need the current [Include] value returned
table results
Account | Visit Date | Dept | Include | Payment | Due | Corrected |
12345A | 1/23/2023 | Diagnostic | N | 280 | 345 | Y |
12345A | 1/23/2023 | Diagnostic | Y | 0 | 345 | N |
12345A | 1/30/2023 | Diagnostic | Y | 25 | 65 | Y |
23569B | 1/31/2023 | Other | Y | 40 | 0 | Y |
I hope this clarifies.
Thanks,
Chase
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
14 | |
12 | |
11 | |
10 | |
9 |