I have a Dataverse table with multiple columns. One of the columns (ColumnA) contains duplicate values. I need to filter the table so that only the first occurrence of each unique value in ColumnA is retained while keeping all other columns intact.
For example, my table looks like this:
ColumnA | ColumnB | ColumnC |
---|---|---|
Alpha | X | 123 |
Alpha | Y | 456 |
Beta | Z | 789 |
Beta | W | 012 |
ColumnA | ColumnB | ColumnC |
---|---|---|
Alpha | X | 123 |
Beta | Z | 789 |
I have tried using Distinct()
, but it only returns ColumnA and removes other columns. First()
also gives errors when used incorrectly.
What is the best approach to achieve this in PowerApps (Dataverse) while keeping all columns?
Any help would be appreciated!
ClearCollect( NewCity,
{ City: "Milan", Country: "Italy", Population: 1344000, DateCreated: DateTimeValue("10/11/2014 9:50:24.765 PM")}
);
ClearCollect( NewCityGrouped, GroupBy( NewCity, Country, Cities ) );
ClearCollect( CityPopulations,
{ City: "London", Country: "United Kingdom", Population: 8615000, DateCreated: DateTimeValue("10/11/2014 1:50:24.765 PM")},
{ City: "Berlin", Country: "Germany", Population: 3562000, DateCreated: DateTimeValue("10/11/2014 2:50:24.765 PM")},
{ City: "Madrid", Country: "Spain", Population: 3165000, DateCreated: DateTimeValue("10/11/2014 3:50:24.765 PM")},
{ City: "Rome", Country: "Italy", Population: 2874000, DateCreated: DateTimeValue("10/11/2014 4:50:24.765 PM")},
{ City: "Paris", Country: "France", Population: 2273000, DateCreated: DateTimeValue("10/11/2014 5:50:24.765 PM")},
{ City: "Hamburg", Country: "Germany", Population: 1760000, DateCreated: DateTimeValue("10/11/2014 6:50:24.765 PM")},
{ City: "Barcelona", Country: "Spain", Population: 1602000, DateCreated: DateTimeValue("10/11/2014 7:50:24.765 PM")},
{ City: "Munich", Country: "Germany", Population: 1494000, DateCreated: DateTimeValue("10/11/2014 7:50:24.765 PM")},
{ City: "Milan", Country: "Italy", Population: 1344000, DateCreated: DateTimeValue("10/11/2014 9:50:24.765 PM")}
);
ClearCollect( CitiesByCountry, GroupBy( CityPopulations, Country, Cities ) );
Clear(NewCityGrouped);
ForAll(CitiesByCountry, Collect(NewCityGrouped, {Country: Country, Cities: Table(First(Sort(Cities,DateCreated)))}));
ClearCollect( NewCityGroupedUngrouped, Ungroup( NewCityGrouped, Cities ) );
Clear(col_DVData);
With(
{
DV_Data: Filter(
YOUR_DATAVERSE_TABLE,
QUERY
)
},
ForAll(
DV_Data As theData,
If(
IsBlank(
LookUp(
col_DVData,
ColumnToCheck = theData.ColumnToCheck
)
),
Collect(
col_DVData,
theData
)
)
)
)
WarrenBelz
146,513
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,636
Most Valuable Professional