Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi,
I have the following dataset. I want to be able to add a column after to label each row as to whether it is a reversal entry or not.
| Vendor ID.# | Name | Invoice No.# | Transaction Amount |
| 600754 | aaaa | 123 | 366 |
| 989111 | bbbb | 234 | 320 |
| 242001 | cccc | 86030 | 242 |
| 242001 | cccc | 86030 | -242 |
I tried using the switch formula like this:
Solved! Go to Solution.
Hi @adbm -Can you please try the below calculated column,it's returning multiple rows when it needs a scalar.
check the calculated column
IsReversal =
VAR CurrentInvoice = 'Vendor data'[Invoice No.#]
VAR CurrentAmount = 'Vendor data'[Transaction Amount]
RETURN
IF(
CALCULATE(
COUNTROWS('Vendor data'),
FILTER(
'Vendor data',
'Vendor data'[Invoice No.#] = CurrentInvoice &&
'Vendor data'[Transaction Amount] = -CurrentAmount
)
) > 0,
"Reversal",
"Not Reversal"
)
Hope we will not an error. it works.
Proud to be a Super User! | |
@adbm , Try using below measure
IsReversal =
VAR CurrentInvoice = 'Vendor data'[Invoice No.#]
VAR CurrentAmount = 'Vendor data'[Transaction Amount]
RETURN
IF (
CALCULATE (
COUNTROWS('Vendor data'),
'Vendor data'[Invoice No.#] = CurrentInvoice,
'Vendor data'[Transaction Amount] = -CurrentAmount
) > 0,
"Reversal",
"Not Reversal"
)
Proud to be a Super User! |
|
Hi @adbm -Can you please try the below calculated column,it's returning multiple rows when it needs a scalar.
check the calculated column
IsReversal =
VAR CurrentInvoice = 'Vendor data'[Invoice No.#]
VAR CurrentAmount = 'Vendor data'[Transaction Amount]
RETURN
IF(
CALCULATE(
COUNTROWS('Vendor data'),
FILTER(
'Vendor data',
'Vendor data'[Invoice No.#] = CurrentInvoice &&
'Vendor data'[Transaction Amount] = -CurrentAmount
)
) > 0,
"Reversal",
"Not Reversal"
)
Hope we will not an error. it works.
Proud to be a Super User! | |
Hi @rajendraongole1 - could you please briefly explain how your formula works but my switch one didnt? i guess its a matter of learning DAX but if you could please explain a bit right now, ill know which direction to head in the next time.
Hi @adbm - Glad it works at your end. Filter is being used incorrectly in the context of the switch statement, as it's returning multiple rows when it needs a scalar (single value).the logic you want have to be implemented using calculate and filter, which will allow you to check for reversal entries row by row.Let me know if any information required from my end/
Hope the above information helps.
Proud to be a Super User! | |
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.