cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cnr
Advocate I
Advocate 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
daruom
Helper II
Helper II

Hello,

I imagine that "UpcomingSettlementsFundsGroupingFunds" is a colletion (or SP list or whatever)?

if so, you have to browse the source in a loop before doing your condition.

 

 

ForAll(
    UpcomingSettlementsFundsGroupingFunds;
    If(
        Choices(ThisRecord.'Transaction Type').value = "sell"
        .....

 

 

Edit: Replace the ";" by ","

Hi @daruom ,

 

It wouldnt allow 

Choices(ThisRecord.'Transaction Type').value = "sell"

 

So I used the below but - I'm getting an error stating "cannot compare a table with text"  on the If Statement

 

cnr_0-1632905652544.png

 

daruom
Helper II
Helper II

Hi @cnr 

Try that :

 

ForAll(
    UpcomingSettlementsFundsGroupingFunds;
    If(
        ThisRecord.'Transaction Type'.value = "sell"
        .....

 

Or UpcomingSettlementsFundsGroupingFunds.settlementDump, I'm not sure about your data source.

 

Also when you do "file> collection" you can see the complex data and field structure, if you have screenshots?

And also put your code in quotes, it will be more readable and practical.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

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