cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
calvares
Continued Contributor
Continued Contributor

Checking if columns in a table match

I have one table UserRecords. There is a person column (supervisor) which also allows for multiple selections. I want to check if all the supervisor columns in this table are the same. Or alternatively if the supervisor column in the first record matches with that in the last record.

 

I know I can use IsMatch if it's text, so I thought I could set a variable for the first and last columns then do an IsMatch between the two. However I can't work out how to set them. I have so far: set(varFirst, LookUp(First(UserRecords), but am missing a condition.

 

Or is there is a much simpler way to match these records?

 

1 ACCEPTED SOLUTION

Accepted Solutions
MichaB12
Helper II
Helper II

Hi, 

 

One thing you could do is use the GroupBy() function.

 

With you example, I added a column to your table where I save the concatenated names of managers. Then I groupBy this new column name. 

 

GroupBy(AddColumns('UserRecords', "supervisorsConcat", Concat(ThisRecord.'supervisor', ThisRecord.DisplayName)), "supervisorsConcat", "Rest")

 

If you have more than 1 row, you are sure that all supervisor are not the same. So you just need to count the row of the previous result.

 

Hope this helps

View solution in original post

4 REPLIES 4
MichaB12
Helper II
Helper II

Hi, 

 

One thing you could do is use the GroupBy() function.

 

With you example, I added a column to your table where I save the concatenated names of managers. Then I groupBy this new column name. 

 

GroupBy(AddColumns('UserRecords', "supervisorsConcat", Concat(ThisRecord.'supervisor', ThisRecord.DisplayName)), "supervisorsConcat", "Rest")

 

If you have more than 1 row, you are sure that all supervisor are not the same. So you just need to count the row of the previous result.

 

Hope this helps

View solution in original post

KvB1
Solution Specialist
Solution Specialist

You basically want to check if, within your collection, there is only 1 supervisor present, or 2?

In which case I think doing a If(CountRows(Distinct(XXX)))=1,yes,no) kinda thing would be the simplest

calvares
Continued Contributor
Continued Contributor

Thanks @MichaB12. That's helpful to know about the GroupBy() function. 

 

My table is a collection so I added the concat column to the ClearCollect, callled SupervisorNames. 

I then added the formula

GroupBy(UserRecords, "SupervisorNames", "GroupSupervisors").

However, I couldn't do a CountRows on the group so I updated my formula to 

CountRows(GroupBy(UserRecords, "SupervisorNames", "GroupSupervisors")) and that seems to have worked! 

 

Thanks again!

calvares
Continued Contributor
Continued Contributor

Thanks for the idea, but I do need to see if there's a match on names.

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

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,856)