How to make a group by query?

Hello, I got the tables User, Action and performed_action. When a user performs a action it gets submitted to the performed_action table. I wanna retrieve the data like this query does:

SELECT action_id, COUNT(*) as count
FROM performed_action
GROUP BY action_id;

Which results in this dataset:
action_id | count
3 -------------- 2
31 ------------ 1

Relation in the User model:

public function getPerformedActions()
    return $this->hasMany(PerformedAction::class, ['user_id' => 'id']);

performed_action table is filled with this data:

What i tried:

$users = \common\models\User::find()
    ->joinWith(['performedActions' => function ($query) {
        $query->select('action_id, COUNT(*) as count')->groupBy('action_id');
$performedActions = $users['performedActions'];

But this returns:

array(0) {

How do i achieve the above dataset in Yii2?

Try to see what is generated query first. Show raw SQL query | Wiki | Yii PHP Framework

SELECT user.* FROM user LEFT JOIN performed_action ON = performed_action.user_id GROUP BY `action_id

This is the query generated