cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JimSabre
Level: Powered On

Switch function not working

I am using a Switch function to analyze two separate variables and display the results in a Gallery. The first match variable is a drop down where I select from a list of pre-defined column label names. The second variable is the text typed into the TextSearchBox1 that allows my user to refine their filter. I currently see in the debug view that the function is working as expected but am not seeing it show in the gallery.

 

Anyone have any ideas on what I may be doing wrong?

 

Function located in the Items Property:

Switch(Dropdown1.SelectedText.Value,"Name of Expense",Filter('Employee Expense Requests',StartsWith('Name of Expense', TextSearchBox1_1.Text),"Name of Expense"),"Director",Filter('Employee Expense Requests', StartsWith(Director, TextSearchBox1_1.Text)),"")

 

Current Page I am working with

EmpExp 1.jpg

 

Debug showing that the function seems to be gathering the correct data.

EmpExp 2.jpg

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Switch function not working

Hi @JimSabre ,

Yeah, you are right. I think this issue is related to the "Director" column (Choice type column) in your SP List.

 

I have made a test on my side, please consider modify your formula as below:

Switch(
       Dropdown1.SelectedText.Value,
       "Name of Expense",
       Filter('Employee Expense Requests', StartsWith('Name of Expense', TextSearchBox1_1.Text)),
       "Director",
       Filter('Employee Expense Requests', StartsWith(Director.Value, TextSearchBox1_1.Text)) // Modify formula here
)

 

If the "Director" column is a Person type column in your SP List, please modify above formula as below:

Switch(
       Dropdown1.SelectedText.Value,
       "Name of Expense",
       Filter('Employee Expense Requests', StartsWith('Name of Expense', TextSearchBox1_1.Text)),
       "Director",
       Filter('Employee Expense Requests', StartsWith(Director.DisplayName, TextSearchBox1_1.Text)) // Modify formula here
)

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
EricLott
Level 10

Re: Switch function not working

This is a guess and may not solve your problem, but the default result, where you have an empty string (""), try changing that to Blank(), since the Items property expects a table.

JimSabre
Level: Powered On

Re: Switch function not working

Thanks Eric, I input that but did not change results. However, it was a good suggestion.  

Community Support Team
Community Support Team

Re: Switch function not working

Hi @JimSabre ,

Could you please share a bit more about the "Name of Expense" column and "Director" column in your data source? Are hey both Text type column?

Could you please show more details about the 'Employee Expense Requests' data source? Is it a SP List?

 

Based on the formula you provided, I think there is something wrong with it. I have made a test on my side, please consider modify your formula as below (set the Items property of the Gallery to following) :

Switch(
       Dropdown1.SelectedText.Value,
       "Name of Expense",
       Filter('Employee Expense Requests', StartsWith('Name of Expense', TextSearchBox1_1.Text)),
       "Director",
       Filter('Employee Expense Requests', StartsWith(Director, TextSearchBox1_1.Text))
)

 

If the  'Employee Expense Requests' is a SP List data source, and the "Director" column is a Person type column in your list, please consider modify above formula as below:

Switch(
       Dropdown1.SelectedText.Value,
       "Name of Expense",
       Filter('Employee Expense Requests', StartsWith('Name of Expense', TextSearchBox1_1.Text)),
       "Director",
       Filter('Employee Expense Requests', StartsWith(Director.DisplayName, TextSearchBox1_1.Text)) // Modify formula here
)

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
JimSabre
Level: Powered On

Re: Switch function not working

Hi Kris,

 

Thanks for the suggestion. I tried the first solution since the "Name of Expense" is a "Single Line of Text" field in a SharePoint list and the "Director" column is a "Choice" field in the same SharePoint list called "Employee Expense Requests".

 

When I used the first suggestion, I get an error "Invalid Argument type (Record). Expecting a text value instead". However, it does not give me any clue on which value is not text. The debug shows good results (see original attachments). But nothing shows in the Gallery.

 

Could it be interpreting the "Director" column as something else since it is a choice field in SharePoint?

 

What other information can I provide that would help?

 

 

Community Support Team
Community Support Team

Re: Switch function not working

Hi @JimSabre ,

Yeah, you are right. I think this issue is related to the "Director" column (Choice type column) in your SP List.

 

I have made a test on my side, please consider modify your formula as below:

Switch(
       Dropdown1.SelectedText.Value,
       "Name of Expense",
       Filter('Employee Expense Requests', StartsWith('Name of Expense', TextSearchBox1_1.Text)),
       "Director",
       Filter('Employee Expense Requests', StartsWith(Director.Value, TextSearchBox1_1.Text)) // Modify formula here
)

 

If the "Director" column is a Person type column in your SP List, please modify above formula as below:

Switch(
       Dropdown1.SelectedText.Value,
       "Name of Expense",
       Filter('Employee Expense Requests', StartsWith('Name of Expense', TextSearchBox1_1.Text)),
       "Director",
       Filter('Employee Expense Requests', StartsWith(Director.DisplayName, TextSearchBox1_1.Text)) // Modify formula here
)

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

JimSabre
Level: Powered On

Re: Switch function not working

That was it! Thanks Kris, you solved the mystery of the Director.  🙂

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

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.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

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 (9,428)