cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
simms7400
Level 8

Weird issues with IF statement

Hi Folks -

 

This is probably VERY easy, but I'm having trouble with an if statement.  It is as follows:

If(
	InvestmentEditForm.Mode=New, {Value:"Not Applicable"},
	Filter(DevicePlatformList, Alias in Split(ThisItem.Device_Platform, ",")).Alias
)

It is not validating.  If I only use one condition, regardless of which one it works.  Why?

9 REPLIES 9
Dual Super User
Dual Super User

Re: Weird issues with IF statement

Where are you using the If statement?  For true I see the declaration of a record, but for false it just retrieves alias.  Is alias a record with just a Value?



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Delid4ve
Level 10

Re: Weird issues with IF statement

Not sure what your trying to do here,
First issue:
=New needs to be ForMode.New
Second issue:
What is Value? Are you trying to set a variable here? If so then: Set(Value, “Not Applicable”)
What is the third part for?
simms7400
Level 8

Re: Weird issues with IF statement

THis formula is going in the Default selected items of a ComboBox...

 

I'm seeing the value to "Not Applicable" if new, otherwise display the results accordingly.

Dual Super User
Dual Super User

Re: Weird issues with IF statement

You can't add a value to a dropdown on the fly like that.  If you want a not applicable value it needs to be one of the values bound to the dropdown.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Highlighted
Delid4ve
Level 10

Re: Weird issues with IF statement

Set your ComboBox items to:
Var_DefaultItems

Wherever you are initialising the form ie navigating from a previous screen, after you have changed the form to new and before the navigate put:
If(InvestmentEditForm.Mode = FormMode.New, Set(Var_DefaultItems,””,filterstatementhere)

This is assuming you want the items in your ComboBox to be empty or the list of fields as per the filter

Hopefully I’ve understood you correctly
simms7400
Level 8

Re: Weird issues with IF statement

@Pstork1  "Not Applicable" is a valid choice in the drop down. The intent is to prepopulate upon NEW and let the user change the value IF needed.

 

@Delid4ve  I'll give that a shot!

 

For some clarity, gents, this works:

If(
	InvestmentEditForm.Mode=New,
	Filter(DevicePlatformList, Alias in Split(ThisItem.Device_Platform, ",")).Alias
)

 

And so does this:

If(
	InvestmentEditForm.Mode=New, {Value:"Not Applicable"}
)

 

But when combined, it doesn't. Thoughts?

Delid4ve
Level 10

Re: Weird issues with IF statement

Can you post a screenshot of the screen and the properties of the form and combo
Community Support Team
Community Support Team

Re: Weird issues with IF statement

Hi @simms7400 ,

Could you tell me whether this field is single choice or multiple choice?

Actually, the two formulas' results are different.

Filter(DevicePlatformList, Alias in Split(ThisItem.Device_Platform, ",")).Alias

This will result a table.

{Value:"Not Applicable"}

 This will result a record.

However, since you need to use these two formulas to set the same filed, you need to make them the same structure.

Could you tell me the data type of Alias? Is it a single choice column?

If so, please try this:

If(
	InvestmentEditForm.Mode=New,
	LookUp(DevicePlatformList, Alias in Split(ThisItem.Device_Platform, ",")).Alias,
{Value:"Not Applicable"}
)

LookUp will only return one record. Filter will return a table.

 

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
simms7400
Level 8

Re: Weird issues with IF statement

@v-yutliu-msft 

 

The field I'm trying to put this logic into a multi-choice combo box.  As you see above, my current formula in the "DefaultSelectedItems" property is as follows:

Filter(DevicePlatformList, Alias in Split(ThisItem.Device_Platform, ",")).Alias

 

And it works fine! However, I want to add an additional layer where if the form is New, then I just want to populate the ComboBox with "Not Applicable" (which is a valid choice).

 

Unfortunately, your suggestion did not work:

Device.png

My Device Platform DataCard is as follows:

DC.png

 

"DevicePlatformList" is my collection which populates my ComboBox called "CB_Device_Platform".

 

Thank you.

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (10,532)