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
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
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,531)