cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NazIM
Frequent Visitor

SQl Get Rows (V2) Unique values

Im struggling with getting only unique values from the SQL Get Rows(V2) output. Has anyone been able to figure it out?

1 ACCEPTED SOLUTION

Accepted Solutions
NazIM
Frequent Visitor

@yashag2255, Didn't try the method shown in the link. 

 

However, what I succeeded with doing is:

1. Get rows (V2) to run the query.

2. put all the field values into an array usig a ForEach action.

3. Used a Union function in a Compose action to union the array with itself

4. Used a join function to create a string from the array.

 

 

image.png

 

Very convoluted, but its the only way I got it to work! Phew!!

View solution in original post

10 REPLIES 10
365-Assist
Advocate III
Advocate III

Perhaps you should use the Get Row Action instead

 

Annotation 2019-10-18 114234.jpg

v-litu-msft
Community Support
Community Support

Hi @NazIM,

 

I found that you have reply a post to a similar question, does that method not work?

https://powerusers.microsoft.com/t5/General-Flow-Discussion/Array-variables-unique-values/m-p/385325...

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

NazIM
Frequent Visitor

Unfortunately not. Get Row does not work with On Premise Data Gateways.

Did try it, but it does not seem to work.

Hi Nazi,

 

My example of Flow with Get Row is connected via an On-Premises Data Gatway to an SQL Database. What error do you get when you try it?

 

NazIM
Frequent Visitor

Just tried again. Get Row (V2) works. I believe the earlier version wasn't.

 

I guess my issue is different though. What I want is the equivalent of "SELECT DISTINCT <Col> .." in SQL (i.e.: Only unique values / no repeats of the same value).

You might try using the "Execute a SQL Query (V2)" action and pass in an actual SELECT DISTINCT query. That's generally the route I take when I need get distinct data.

yashag2255
Dual Super User II
Dual Super User II

Hey @NazIM 

 

In case you do not plan to go an alternate way of performing the sql query, you can use the below method to identify the unique values by creating arrays: 

https://powerusers.microsoft.com/t5/Microsoft-Flow-Community-Blog/Delete-duplicate-records-items-fro...

 

Hope this Helps!

 

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

NazIM
Frequent Visitor

@ : That's not supported with On-Premise Data Gateway:

 

image.png

 

NazIM
Frequent Visitor

@yashag2255, Didn't try the method shown in the link. 

 

However, what I succeeded with doing is:

1. Get rows (V2) to run the query.

2. put all the field values into an array usig a ForEach action.

3. Used a Union function in a Compose action to union the array with itself

4. Used a join function to create a string from the array.

 

 

image.png

 

Very convoluted, but its the only way I got it to work! Phew!!

View solution in original post

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,263)