Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Count with filter

Bonjour,  J'ai cette formule qui calcule le nombre de salariés qui sont inscrit CALCULATE(DISTINCTCOUNT('DIM - Inscription'[Key_base_inscription]),'DIM - Inscription','DIM - Inscription'[Etat d'ins...
  • ERD's avatar
    3 years ago

    Anonymous , vous pouvez utiliser la formule comme suit:

    inscrit =
    VAR real =
        CALCULATETABLE (
            VALUES ( 'DIM - Inscription'[Key_base_inscription] ),
            'DIM - Inscription'[Etat d'inscription]
                IN { "Réalisé", "Partiellement Réalisé" }
        )
    VAR inscrit =
        CALCULATETABLE (
            VALUES ( 'DIM - Inscription'[Key_base_inscription] ),
            'DIM - Inscription'[Etat d'inscription]
                IN {
                    "Inscrit libre-accès",
                    "Inscription validées",
                    "Convoqué sans notification",
                    "Convoqué avec notification"
                }
        )
    VAR excl = EXCEPT ( inscrit, real )
    RETURN
        CALCULATE ( DISTINCTCOUNT ( 'DIM - Inscription'[Key_base_inscription] ), excl )

     

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

    One way to exclude employees who have a completed enrolment status is to use the EXCEPT function, which returns a table that contains the rows of one table minus all the rows of another table.

    Registered Not Completed =
    VAR Registered =
        FILTER (
            'DIM - Inscription',
            'DIM - Inscription'[Inscription status]
                IN {
                    "Inscrit libre-accès",
                    "Inscription validées",
                    "Convoqué sans notification",
                    "Convoqué avec notification"
                }
        )
    VAR Completed =
        FILTER (
            'DIM - Inscription',
            'DIM - Inscription'[Inscription status] IN { "Realized", "Partially Realized" }
        )
    VAR Result =
        EXCEPT ( Registered, Completed )
    RETURN
        DISTINCTCOUNT ( Result[Key_base_inscription] )
    

    Another way to exclude employees who have a completed enrolment status is to use the NOT and IN operators, which allow you to specify a logical condition that negates or includes a set of values.

    Registered Not Completed =
    CALCULATE (
        DISTINCTCOUNT ( 'DIM - Inscription'[Key_base_inscription] ),
        KEEPFILTERS ( NOT 'DIM - Inscription'[Inscription status] IN { "Realized", "Partially Realized" } )
    )
    

     

     

    How to Get Your Question Answered Quickly 

     

    If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

     

    Best Regards
    Community Support Team _ Rongtie

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.