iRon7 / Join-Object

Combines two objects lists based on a related property between them.
MIT License
107 stars 13 forks source link

Exclude identical objects on a self join where the `-equal` parameter is omitted #37

Closed iRon7 closed 1 year ago

iRon7 commented 1 year ago

Exclude identical objects (with the same index) on a self-join where the -On parameter is supplied and -equal parameter is omitted On a self-join with only a -on parameter and no -equal parameter objects will always related to their self an therefore useless to include Where a self-join without an -on parameter (on index) is completely useless and shouldn't be accepted

iRon7 commented 1 year ago
$Department = ConvertFrom-Csv @'
"Name","Country"
"Engineering","Germany"
"Marketing","England"
"Sales","France"
"Purchase","France"
'@

Join $Department -on Country -Name *1,*2 # Or: $Department |Join -on Country -Name *1,*2

Name1    Name2    Country
-----    -----    -------
Sales    Purchase France
Purchase Sales    France

To get same behavior as previous versions, use both the -on and the -equals parameter:


Join $Department -on Country -eq Country -Name *1,*2