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

If Else in Drop Down

Dear, the community can someone help me with this error?
 I'm currently working in the data that is not in the database and shows "N/A", I'm using the if else statement inside the properties of the item in a dropdown

 

===My Code===

If(IsBlank(Last(Filter(submission,txt_PartNum_1.Text in 'part#' && "LIMS PHT" in testing).'batch#')),["N/A"],Last(Filter(submission,txt_PartNum_1.Text in 'part#' && "LIMS PHT" in testing).'batch#'))

 

Thank you

 

1 ACCEPTED SOLUTION

Accepted Solutions
BCBuizer
Super User
Super User

HI @Kint4 ,

 

So you need to display either the last value or "N/A"? In that case, why use a dropdown? A label then makes more sense.



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

View solution in original post

5 REPLIES 5
BCBuizer
Super User
Super User

Hi @Kint4 ,

 

I assume the error you are receiving is "Expected Table vale"?

 

To resolve that, you need to remove the Last in the Else statement:

 

If(
	IsBlank(
		Last(
			Filter(
				submission,
				txt_PartNum_1.Text in 'part#' && "LIMS PHT" in testing
			).'batch#'
		)
	),
	["N/A"],
	Filter(
		submission,
		txt_PartNum_1.Text in 'part#' && "LIMS PHT" in testing
	).'batch#'
)

 

To further simplify this code, you can use a With function:

With({
	_items: Filter(
		submission,
		txt_PartNum_1.Text in 'part#' && "LIMS PHT" in testing
		).'batch#'
	},
	If(
		IsEmpty(_items), 
		["N/A"],
		_items
	)
)


Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

Thanks for the reply @BCBuizer, but I need to display the latest value of the Batch# itself.
I already try your code, and it works but only displays the first value.

Any other idea?

BCBuizer
Super User
Super User

HI @Kint4 ,

 

So you need to display either the last value or "N/A"? In that case, why use a dropdown? A label then makes more sense.



Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.

Hi, @BCBuizer 
I got an error, How do i solve this?

Kint4_0-1671765594602.png

the error is invalid argument type(record), expecting a text value instead

 

Hi, @BCBuizer .
I already find the solution, I change the isBlank to IsEmpty.

Thank you so much for the help ^^

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.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

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,213)