Hey all,
I know there are a lot of topics explaining this one. But I could't find what I'm looking for, because I want:
What I'm having that I have to select all four Comboboxes to get results.
What I want:
That code i'm using:
If(IsBlank(ComboBox1.Selected.Result) && IsBlank(ComboBox2.Selected.Result) && IsBlank(ComboBox3.Selected.Result) && IsBlank(ComboBox4.Selected.Result),SortByColumns(TasksData,"Title",Descending),SortByColumns(Filter(TasksData,StartsWith(TaskTarget,ComboBox1.Selected.Result),StartsWith(TaskCenter,ComboBox2.Selected.Result),StartsWith(Employee,ComboBox3.Selected.Result),StartsWith(TaskSubject,ComboBox4.Selected.Result)),"Title",Descending))
Solved! Go to Solution.
Here is sample of filtering datasource with 4 comboboxes. I only covered 8 switches so you will have to finish it co cover all scenario
Switch(true, IsBlank(ComboBox1.Selected.Text1) && IsBlank(ComboBox2.Selected.Text1) && IsBlank(ComboBox3.Selected.Text1) && IsBlank(ComboBox4.Selected.Text1), TestColection,
Not(IsBlank(ComboBox1.Selected.Text1)) && IsBlank(ComboBox2.Selected.Text1) && IsBlank(ComboBox3.Selected.Text1) && IsBlank(ComboBox4.Selected.Text1), Filter(TestColection,Col1=ComboBox1.Selected.Text1), Not(IsBlank(ComboBox1.Selected.Text1)) && Not(IsBlank(ComboBox2.Selected.Text1)) && IsBlank(ComboBox3.Selected.Text1) && IsBlank(ComboBox4.Selected.Text1), Filter(TestColection,Col1=ComboBox1.Selected.Text1 && Col2=ComboBox2.Selected.Text1), Not(IsBlank(ComboBox1.Selected.Text1)) && Not(IsBlank(ComboBox2.Selected.Text1)) && Not(IsBlank(ComboBox3.Selected.Text1)) && IsBlank(ComboBox4.Selected.Text1), Filter(TestColection,Col1=ComboBox1.Selected.Text1 && Col2=ComboBox2.Selected.Text1 && Col3=ComboBox3.Selected.Text1), Not(IsBlank(ComboBox1.Selected.Text1)) && Not(IsBlank(ComboBox2.Selected.Text1)) && Not(IsBlank(ComboBox3.Selected.Text1)) && Not(IsBlank(ComboBox4.Selected.Text1)), Filter(TestColection,Col1=ComboBox1.Selected.Text1 && Col2=ComboBox2.Selected.Text1 && Col3=ComboBox3.Selected.Text1 && Col3=ComboBox4.Selected.Text1), IsBlank(ComboBox1.Selected.Text1) && Not(IsBlank(ComboBox2.Selected.Text1)) && IsBlank(ComboBox3.Selected.Text1) && IsBlank(ComboBox4.Selected.Text1), Filter(TestColection,Col1=ComboBox2.Selected.Text1), IsBlank(ComboBox1.Selected.Text1) && Not(IsBlank(ComboBox2.Selected.Text1)) && Not(IsBlank(ComboBox3.Selected.Text1)) && IsBlank(ComboBox4.Selected.Text1), Filter(TestColection,Col1=ComboBox2.Selected.Text1 && Col2=ComboBox3.Selected.Text1), IsBlank(ComboBox1.Selected.Text1) && Not(IsBlank(ComboBox2.Selected.Text1)) && Not(IsBlank(ComboBox3.Selected.Text1)) && Not(IsBlank(ComboBox4.Selected.Text1)), Filter(TestColection,Col1=ComboBox2.Selected.Text1 && Col2=ComboBox3.Selected.Text1 && Col3=ComboBox4.Selected.Text1)
.
.
.)
Can you provide me with a quick example on how I'm gonna do it?
Here is sample of filtering datasource with 4 comboboxes. I only covered 8 switches so you will have to finish it co cover all scenario
Switch(true, IsBlank(ComboBox1.Selected.Text1) && IsBlank(ComboBox2.Selected.Text1) && IsBlank(ComboBox3.Selected.Text1) && IsBlank(ComboBox4.Selected.Text1), TestColection,
Not(IsBlank(ComboBox1.Selected.Text1)) && IsBlank(ComboBox2.Selected.Text1) && IsBlank(ComboBox3.Selected.Text1) && IsBlank(ComboBox4.Selected.Text1), Filter(TestColection,Col1=ComboBox1.Selected.Text1), Not(IsBlank(ComboBox1.Selected.Text1)) && Not(IsBlank(ComboBox2.Selected.Text1)) && IsBlank(ComboBox3.Selected.Text1) && IsBlank(ComboBox4.Selected.Text1), Filter(TestColection,Col1=ComboBox1.Selected.Text1 && Col2=ComboBox2.Selected.Text1), Not(IsBlank(ComboBox1.Selected.Text1)) && Not(IsBlank(ComboBox2.Selected.Text1)) && Not(IsBlank(ComboBox3.Selected.Text1)) && IsBlank(ComboBox4.Selected.Text1), Filter(TestColection,Col1=ComboBox1.Selected.Text1 && Col2=ComboBox2.Selected.Text1 && Col3=ComboBox3.Selected.Text1), Not(IsBlank(ComboBox1.Selected.Text1)) && Not(IsBlank(ComboBox2.Selected.Text1)) && Not(IsBlank(ComboBox3.Selected.Text1)) && Not(IsBlank(ComboBox4.Selected.Text1)), Filter(TestColection,Col1=ComboBox1.Selected.Text1 && Col2=ComboBox2.Selected.Text1 && Col3=ComboBox3.Selected.Text1 && Col3=ComboBox4.Selected.Text1), IsBlank(ComboBox1.Selected.Text1) && Not(IsBlank(ComboBox2.Selected.Text1)) && IsBlank(ComboBox3.Selected.Text1) && IsBlank(ComboBox4.Selected.Text1), Filter(TestColection,Col1=ComboBox2.Selected.Text1), IsBlank(ComboBox1.Selected.Text1) && Not(IsBlank(ComboBox2.Selected.Text1)) && Not(IsBlank(ComboBox3.Selected.Text1)) && IsBlank(ComboBox4.Selected.Text1), Filter(TestColection,Col1=ComboBox2.Selected.Text1 && Col2=ComboBox3.Selected.Text1), IsBlank(ComboBox1.Selected.Text1) && Not(IsBlank(ComboBox2.Selected.Text1)) && Not(IsBlank(ComboBox3.Selected.Text1)) && Not(IsBlank(ComboBox4.Selected.Text1)), Filter(TestColection,Col1=ComboBox2.Selected.Text1 && Col2=ComboBox3.Selected.Text1 && Col3=ComboBox4.Selected.Text1)
.
.
.)
Wow Sienna, you are wonderful thanks.
I did something like this yesterday:
If(IsBlank(first.Text)&&IsBlank(second.Text)&&IsBlank(third.Text)&&IsBlank(fourth.Text),SortByColumns(TasksData,"Title",Descending),If(Not(IsBlank(first.Text))&&Not(IsBlank(second.Text))&&Not(IsBlank(third.Text))&&Not(IsBlank(fourth.Text)),SortByColumns(Filter(TasksData,TaskTarget=first.Text,TaskCenter=second.Text,Employee=third.Text,TaskSubject=fourth.Text),"Title",Descending),If(Not(IsBlank(first.Text))&&Not(IsBlank(second.Text))&&IsBlank(third.Text)&&Not(IsBlank(fourth.Text)),SortByColumns(Filter(TasksData,TaskTarget=first.Text,TaskCenter=second.Text,TaskSubject=fourth.Text),"Title",Descending),If(Not(IsBlank(first.Text))&&IsBlank(second.Text)&&Not(IsBlank(third.Text))&&Not(IsBlank(fourth.Text)),SortByColumns(Filter(TasksData,TaskTarget=first.Text,Employee=third.Text,TaskSubject=fourth.Text),"Title",Descending),If(Not(IsBlank(first.Text))&&Not(IsBlank(second.Text))&&Not(IsBlank(third.Text))&&IsBlank(fourth.Text),SortByColumns(Filter(TasksData,TaskTarget=first.Text,TaskCenter=second.Text,Employee=third.Text),"Title",Descending),If(IsBlank(first.Text)&&Not(IsBlank(second.Text))&&Not(IsBlank(third.Text))&&Not(IsBlank(fourth.Text)),SortByColumns(Filter(TasksData,TaskCenter=second.Text,Employee=third.Text,TaskSubject=fourth.Text),"Title",Descending),If(Not(IsBlank(first.Text))&&IsBlank(second.Text)&&IsBlank(third.Text)&&Not(IsBlank(fourth.Text)),SortByColumns(Filter(TasksData,TaskTarget=first.Text,TaskSubject=fourth.Text),"Title",Descending),If(Not(IsBlank(first.Text))&&IsBlank(second.Text)&&Not(IsBlank(third.Text))&&IsBlank(fourth.Text),SortByColumns(Filter(TasksData,TaskTarget=first.Text,Employee=third.Text),"Title",Descending),If(Not(IsBlank(first.Text))&&Not(IsBlank(second.Text))&&IsBlank(third.Text)&&IsBlank(fourth.Text),SortByColumns(Filter(TasksData,TaskTarget=first.Text,TaskCenter=second.Text),"Title",Descending),If(IsBlank(first.Text)&&Not(IsBlank(second.Text))&&IsBlank(third.Text)&&Not(IsBlank(fourth.Text)),SortByColumns(Filter(TasksData,TaskCenter=second.Text,TaskSubject=fourth.Text),"Title",Descending),If(IsBlank(first.Text)&&Not(IsBlank(second.Text))&&Not(IsBlank(third.Text))&&IsBlank(fourth.Text),SortByColumns(Filter(TasksData,TaskCenter=second.Text,Employee=third.Text),"Title",Descending),If(IsBlank(first.Text)&&IsBlank(second.Text)&&Not(IsBlank(third.Text))&&Not(IsBlank(fourth.Text)),SortByColumns(Filter(TasksData,Employee=third.Text,TaskSubject=fourth.Text),"Title",Descending),If(Not(IsBlank(first.Text))&&IsBlank(second.Text)&&IsBlank(third.Text)&&IsBlank(fourth.Text),SortByColumns(Filter(TasksData,TaskTarget=first.Text),"Title",Descending),If(IsBlank(first.Text)&&Not(IsBlank(second.Text))&&IsBlank(third.Text)&&IsBlank(fourth.Text),SortByColumns(Filter(TasksData,TaskCenter=second.Text),"Title",Descending),If(IsBlank(first.Text)&&IsBlank(second.Text)&&Not(IsBlank(third.Text))&&IsBlank(fourth.Text),SortByColumns(Filter(TasksData,Employee=third.Text),"Title",Descending),If(IsBlank(first.Text)&&IsBlank(second.Text)&&IsBlank(third.Text)&&Not(IsBlank(fourth.Text)),SortByColumns(Filter(TasksData,TaskSubject=fourth.Text),"Title",Descending)))))))))))))))))
I didn't use the Switch because I didn't understand it.
Is it better to use the Switch you provided or I can do it with an If like I did?
Thank you again
You can use "if" if you like. I prefer to use switch because the code is less messy