Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
User | Count |
---|---|
25 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
27 | |
13 | |
11 | |
9 | |
6 |