cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JimSabre
Frequent Visitor

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

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
Resident Rockstar
Resident Rockstar

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.

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

v-xida-msft
Community Support
Community Support

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.

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?

 

 

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

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

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,148)