cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
diegoadum
Level: Powered On

Get distinct values from a DataSource during the collect process

Hi folks, I'm trying to get just distinct values during the Collect process and can't figurate out how to do that.

 

My goal is to read the F4211 table (Order Details) but just the OrderHeather info. So I'm trying to get only a few fields. Due to the table is meant to hold the OrderDetails, getting only the mentioned fields I'm going to get only the necessary info for the heather. The Customers' collection is a simple collection with some customers.

 

ForAll(Customers,
Collect( OrdersHeathers,
ShowColumns(
Filter( '[dbo].[F4211]', SDDRQJ >= 119001 && SDAN8=ABAN8 ),
"SDDOCO",
"SDDCTO",
"SDMCU",
"SDAN8",
"SDDRQJ",
"SDNXTR",
"SDLTTR"
)
)
)

 

So, I don't know where to put the distinct command here.

 

Thank a lot for any guidance!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Get distinct values from a DataSource during the collect process

Hi @diegoadum 

You would use Distinct() on the datasource and the column that you wanted to get distinct values on.  This would produce a single column table with the column named Result.  You could then add back the other columns with Lookup().  For example, if you wanted distinct values for the SDDRQJ field,  

Distinct ( '[dbo].[F4211]', SDDRQJ)

Would produce a single column table of unique SDDRQJ values.  Then you would add back the columns you wanted as a collection.

Collect( OrdersHeathers,AddColumns(Distinct ( '[dbo].[F4211]', SDDRQJ),"Column1",
Lookup('[dbo].[F4211]',SDDRQJ=Result,SDDOCO),"Column2",Lookup('[dbo].[F4211]',SDDRQJ=Result,SDDCTO),"Column3",Lookup...

This would then produce a collection "OrdersHeathers", that contained only unique values for SDDRQJ but also the associated columns for the other fields.  You could then use this collection in other formulas. 

2 REPLIES 2
Highlighted
Super User
Super User

Re: Get distinct values from a DataSource during the collect process

Hi @diegoadum 

You would use Distinct() on the datasource and the column that you wanted to get distinct values on.  This would produce a single column table with the column named Result.  You could then add back the other columns with Lookup().  For example, if you wanted distinct values for the SDDRQJ field,  

Distinct ( '[dbo].[F4211]', SDDRQJ)

Would produce a single column table of unique SDDRQJ values.  Then you would add back the columns you wanted as a collection.

Collect( OrdersHeathers,AddColumns(Distinct ( '[dbo].[F4211]', SDDRQJ),"Column1",
Lookup('[dbo].[F4211]',SDDRQJ=Result,SDDOCO),"Column2",Lookup('[dbo].[F4211]',SDDRQJ=Result,SDDCTO),"Column3",Lookup...

This would then produce a collection "OrdersHeathers", that contained only unique values for SDDRQJ but also the associated columns for the other fields.  You could then use this collection in other formulas. 

diegoadum
Level: Powered On

Re: Get distinct values from a DataSource during the collect process

Thank for your info! I think if we need to make more than one column as unique we need to concatenate the columns to produce just one and then move forward with the lookup!

 

Thank again!!

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, August 21st at 8am PDT

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

SixthImage

Power Summit Australia 2019

August 20-23rd 2019

Users Online
Currently online: 181 members 4,067 guests
Please welcome our newest community members: