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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
adbm
Helper I
Helper I

using switch to evaluate reversal entries

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.#NameInvoice No.# Transaction Amount 
600754aaaa123366
989111bbbb234320
242001cccc86030242
242001cccc86030-242

 

I tried using the switch formula like this: 

IsReversal =
SWITCH(
    TRUE(),
    AND(FILTER('Vendor data','Vendor data'[Reference No.#] = EARLIER('Vendor data'[Reference No.#])),(FILTER('Vendor data','Vendor data'[Transaction Amount] = -'Vendor data'[Transaction Amount]))),"Reversal","Not Reversal")
 
But Power bi then gives me the following error "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value"
I'm not able to get past this error; it ried removing the filter expression - it didnt work, i tried replacing it with hasonevalue - it didnt work ... im not sure what to do next.
Basically i need the column to show a result as "Reversal" in the rows where invoice number is the same and the transaction amts are the same with one being -ve and the other being a +ve value.
 
Can someone please help me resolve this error?
 
Thanks a lot for your help.
 
Best, Natali
1 ACCEPTED SOLUTION
rajendraongole1
Super User
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.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

5 REPLIES 5
adbm
Helper I
Helper I

Thanks @rajendraongole1  - this worked.

bhanu_gautam
Super User
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"
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






rajendraongole1
Super User
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.





Did I answer your question? Mark my post as a solution!

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. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors