class User ....
public function getNapravlenie(){
return $this->hasMany(Napravlenie::className(),['historyID'=>'id']);
}
public function getAnaliz(){
return $this->hasMany(CheckAnaliz::className(), ['napravlenieID' => 'id'])->via('napravlenie');
}
public function getAnalizCount(){
return count($this->analiz);
}
....
$users = Users::find()->with(['analiz','napravlenie'])->all();
foreach($users as $one){
echo $one->id . " = " . $one->analizCount;
}