Hi all
I have a Sharepoint list with the following values:
Year Test Scenario
2019 Test A Scen-A
2019 Test A Scen-B
2020 Test B Scen-C
In Powerapps, I have a dropdown that filters the Year column to show only distinct values (2019 & 2020). This is fine.
What I then need though is a data table, displaying only 2 columns (Year & Test), where the Year is equal to the dropdown value selected, but only shows the unique combinations of Year and Test.
So, selecting 2019 from the dropdown I need to display a datable with only one row, showing:
Year Test
2019 Test A
If that can't be done - then actually just a table showing unique Test values would be fine (so just showing Test A in this example - as the dropdown would show the year already).
Can anyone help with how I need to do this please? I've been looking at GroupBy, but can't seem to work out the syntax required for the Data Table Items property.
Many thanks...
Paul
@ffabdon ,
You would need something like
AddColumns(
GroupBy(
AddColumns(
Filter(
DataSource,
Asset = SearchFld_1.Selected.Value
),
"InsuranceID",
Left(INSURANCE_ID, 10)
),
"InsuranceID",
"Data"
),
"Asset",
First(Data).ASSET"
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
MVP (Business Applications) Visit my blog Practical Power Apps
Thank you @WarrenBelz but it didnt work for me? 😞 maybe i did it wrong?
My current table was the result of this code:
Filter(
tblInsurance,
ASSET=SearchFld_1.Selected.Value
)
The value of my SearchFld_1.Selected.Value = "ABCD"
The name of the first column
CURRENT TABLE
@ffabdon ,
You have not included any field names - so use yours where I have first and second
AddColumns(
GroupBy(
AddColumns(
DataSource,
"NewField",
Left(FirstFieldName, 10)
),
"NewField",
"Data"
),
"OtherField",
First(Data).SecondFieldName"
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
MVP (Business Applications) Visit my blog Practical Power Apps
Hi,
I am desperately in need of your help please. can you please advise how i can use distinct for below?
CURRENT TABLE
I wanted to have as a RESULT,
Looking forward to your help please
Hi,
Many thanks for your suggestion. I've now found an alternative solution which was:
On the Items property of the Data Table, simply put: First(Filter(DataSource, Title=Dropdown.selectedText.value))
For the scenario I had, this suits the requirement.
Thanks again though.
Paul
Hi
Thanks for your help. It's much appreciated, as this has had me spinning for hours.
I actually came across another solution which should work well enough for now, which didn't require the creation of a collection in this case.
On the Items property of the Data Table, simply put: First(Filter(DataSource, Title=Dropdown.selectedText.value))
Thanks again.
There are no silly questions here my friend. Ask away! Please use my code in the OnChange property of the DataTable.
Then put the collection in the Items property of the data table like this.
colDataTable
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
Hi,
Many thanks for your reply, unfortunately I can't seem to get it to work though......are you able to see where I'm going wrong?
Firstly, the ClearCollect statement. Should that go on a button or on the change of the dropdown selection.....or does it go on the Items property of the Data Table?
Sorry - I'll ask some silly questions as I'm going around in circles with this one.
Thanks,
Paul
Hi @PJBruen
Just to add to @mdevaney's reply and to suggest something else without using ForAll, you should just be able to return a single column table with the distinct tests like so:
Distinct(Filter(Scenarios, ThisRecord.Year= cboYear.Selected.Value),Test)
If you want to add the year column back in, here's the formula you would use:
AddColumns(Distinct(Filter(Scenarios, ThisRecord.Year= cboYear.Selected.Value),Test),
"Year",
cboYear.Selected.Value
)
My idea is to do this and put the data into a collection called colDataTable
ClearCollect(colDataTable, ForAll(Distinct(ShowColumns(Filter(your_datasource_name, Year=Dropdown_Year.Selected,Value), “Year”, “Test”), ThisRecord), ThisRecord.Result)
Here’s a simpler example of how to get the unique records in a collection.
https://matthewdevaney.com/powerapps-collections-cookbook/unique-records-in-a-collection/
WarrenBelz
48
Most Valuable Professional
mmbr1606
41
Super User 2025 Season 1
MS.Ragavendar
36