cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cnr
Helper I
Helper I

If statement based on a Choice field

Hi,

 

Im trying to create an If Statement so that if the choice field is a Sell, I Sum the amount and if its a Buy I add Subtract the amount by multiplying it by -1.

 

My error is saying incompatible types for comparison. But it will not work if I set it to .Value either posted below

 

cnr_1-1632744457965.png

 

cnr_3-1632744846748.png

 

 

12 REPLIES 12
Nogueira1306
Community Champion
Community Champion

'Transaction Type'.Value = "Sell"

 

Try that

 

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Check my LinkedIn!

Check my User Group (pt-PT)!

Hi  @Nogueira1306 

 

Thanks for responding, I tried that along with the below but neither work.

 

I get the following errors:

 

cnr_2-1632745617137.png

cnr_3-1632745673188.png

 

 

Unfortunately that doesnt work

cnr_0-1632745483941.png

 

cnr_1-1632745579238.png

 

 

Nogueira1306
Community Champion
Community Champion

In the last one I am sure it should be only "Sell"

 

Do you have that on a gallery or soemthing?

Try:

 

ThisItem.'Transaction Type'. Value = "Sell"

 

We just need to identify which item we want to compare. 

If you need to comapre all, use a ForAll()

If you need additional help please tag me in your reply and please like my reply.
If my reply provided you with a solution, pleased mark it as a solution ✔️!

Best regards,
Gonçalo Nogueira

Check my LinkedIn!

Check my User Group (pt-PT)!

 

timl
Super User
Super User

Hi @cnr 

This is most likely a disambiguation issue that relates to referencing 'Transaction Type'  inside a call a call to AddColumns,

I'd try the following syntax to see if that works...

 

If(
   'Transaction Type' = [@'Transaction Type'].Sell

 

 

Hi @timl 

 

Thanks for the response,

 

I'm very confused by this because I used a similar method on a different screen shown here which did work:

 

cnr_2-1632755294685.png

 

 

I tried that but didnt work, what do you mean by a call a call to AddColumns?

 

cnr_0-1632755158042.png

cnr_1-1632755181263.png

 

@Hi @Nogueira1306 ,

 

Yeah I tried that - Says it cannot compare a table and text

cnr_5-1632755673603.png

 

I dont understand because I created a similar if statement with the same kind of logic on a choice field and it did work:

cnr_6-1632755798204.png

 

 

I created a Clearcollect in a button where I sum up all my values and then ThisItem.NetAmount.

 

But I need the Amounts to Sum positively if its a Sell and negatively if its a Buy

timl
Super User
Super User

Hi @cnr 

Can you confirm that 'Transaction Type' is a single select 'Choice' column, rather than a multi select 'Choices' column, as this could account for the incompatible type error?

cnr
Helper I
Helper I

Hi @timl 

 

Yes its a single select 'Choice' column

 

Thanks

Conor

timl
Super User
Super User

@cnr 

To diagnose this further, I would try renaming the Transaction Type field to something like TransType, to remove any ambiguity in naming. If you try the formula below, does that result in the same error?

AddColumns(
  RenameColumns(UpcomingSettlementFundsGroupingFunds,
               "Transaction Type",
               "TransType"),
  "Netting TPlusOne",
  If(
     TransType = [@'Transaction Type'].Sell

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,744)