cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cnr
Advocate II
Advocate II

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

'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

 

 

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
Advocate II
Advocate II

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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (1,572)