It does work for me with my sample data. Could you please post a few sanitized but still representative rows of your CSV file? Please format it as code.
Then I removed these changes and tested it again with my code…
$filepath = "C:\path\to\csv"
$CSV = Import-Csv -Path $filepath -Delimiter ";" -Encoding UTF8
$a =$CSV | Where-Object {$_.PersonalArea -eq "myLocation" -and $_.Employeenumber}
$a.count
#count lines where the expression is true
#$a.count
#count all lines except op the first one
$CSV.count
The output is correct in both test cases.
Thank you. Could you explain why you are using $.Employeenumber instead of $.Employeenumber -ne ’ ’ ? Is it just shorter or is there another reason?
I think the problem was the piping of Measure-Object
Ooops … I missed that completely until you just mentioned it now. Sorry.
Mostly I’m really bad with explaining of what’s going on under the hood. Personally I like to write the code as short as possible but still as descriptive and detailed as possible without using aliasses or abbreviations.