Hello,
I'm trying to apply a distinct function to a gallery. but I'm missing something. below is my current formula.
Sort(Search(Distinct(Filter('Office', Department = ListDeptBox.Selected.Abriviation),email1).Result),ListSearchBox.Text,"ID","CName","Fname"),Fname,Ascending)
If I remove the distinct function from the formula above, everything is working fine.
Thanks,
Omi
Solved! Go to Solution.
So this still goes back to my original dilema...if you Distinct that example I gave before and want to use the Column1 value...which would you use?
You can group your data by the Person, but you would then be dealing with then not being able to determine what value of a project you need to display. Perhaps that is not important.
You can consider the following:
On your Items property of the Combobox, set it to:
AddColumns(
GroupBy(yourDataSource,
"yourDepartmentColumnName",
"_records"
),
"_distinctPeople",
GroupBy(_records,
"yourPersonColumnName",
"_projects"
)
)
Then set your Gallery Items property to:
yourCombobox.Selected._distinctPeople
_distinctPeople will be a table of two columns - one is yourPersonColumnName and the other is called _projects and will be a table of all the projects that match the person.
I'm still unclear on exactly what your goal is, so this may or may not be your solution. But, this will give you a distinct capability without losing the data associated with the distinct function.
Distinct returns a table with only ONE column called Result. If you use that in your formula, then you will not have any fields to sort or filter on.
Please consider changing your Formula to the following:
Distinct(
Sort(
Search(
Filter('Office', Department = ListDeptBox.Selected.Abriviation),
ListSearchBox.Text,"ID","CName","Fname"
),
Fname,Ascending
),
email1
)
Keep in mind that this still will return only a table with a single column called result (perhaps that is what you want), but the Search and sort will now work for you.
I hope this is helpful for you.
Keep in mind that this still will return only a table with a single column called result (perhaps that is what you want), but the Search and sort will now work for you.
You will not have an Fname column in your gallery...only a Result column.
Using Distinct implies that you are trying to only have a list of unique information. If you "distinct" a list, none of the other columns play into it. If you have a table like this:
Title | Column1 |
A | 2 |
B | 4 |
B | 6 |
A | 7 |
And you "Distinct" on Title, you would have two records: A and B. If you then wanted to refer to a Column1 value, how would you know which one to refer to? For A - 2 or 7? for B - 4 or 6?
This is the thing about Distinct and perhaps why this is not the right function for your purpose.
Thanks for clearing my thoughts about distinct function. Is there any other way I can use to accomplish the logic?
Best,
Omi
Well, the thing is, I don't know what your logic is? What are you trying to accomplish?
I have a table called "office" in which I have people's details working or have worked on different projects from different departments.
On the app's screen, I have Combobox to filter department and a text box to search specific employees. Now what is happening, when I select the department from Combobox, the gallery shows multiple entries for a single employee. this is where I want to use a distinct function.
Best,
Omi
Is your combobox multi-select or single select?
When you say that you have multiple entries for a single employee, is that because it is a different department or different project?
What is it that you ultimately want to display in your gallery?
Perhaps a screenshot might help some too.
Combobox is set to single select.
Multiple entries because: from the same department: a single person working on multiple projects. I just want to display unique people from each department.
Best,
Omi
So this still goes back to my original dilema...if you Distinct that example I gave before and want to use the Column1 value...which would you use?
You can group your data by the Person, but you would then be dealing with then not being able to determine what value of a project you need to display. Perhaps that is not important.
You can consider the following:
On your Items property of the Combobox, set it to:
AddColumns(
GroupBy(yourDataSource,
"yourDepartmentColumnName",
"_records"
),
"_distinctPeople",
GroupBy(_records,
"yourPersonColumnName",
"_projects"
)
)
Then set your Gallery Items property to:
yourCombobox.Selected._distinctPeople
_distinctPeople will be a table of two columns - one is yourPersonColumnName and the other is called _projects and will be a table of all the projects that match the person.
I'm still unclear on exactly what your goal is, so this may or may not be your solution. But, this will give you a distinct capability without losing the data associated with the distinct function.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
User | Count |
---|---|
184 | |
51 | |
47 | |
32 | |
32 |
User | Count |
---|---|
265 | |
91 | |
78 | |
68 | |
67 |