Forum Discussion

phelms's avatar
phelms
Frequent Visitor
8 years ago
Solved

Count results with dynamic filtering

I am trying to count how many agent that is on target at least 75% of the time in percentage of total number of agents on work in the same period, and show that on a single card. 

 

In a table, that is pretty straight forward to calculate per agent, using this measure: SUM([on target]) / SUM([at work]), but I can not seem to figure out how to get the total percentage of agents that were on target at least 75% of the time, to show.

 

Also, I want the calculation to be dynamic, so that I can change the week range in a slicer to adjust the result accordingly.

 

What am I missing?

 

Data table:

fullnameweekon targetoff targetat work
Agent112101
Agent27101
Agent211011
Agent210011
Agent29011
Agent28011
Agent25011
Agent23011
Agent21011
Agent24011
Agent22011
Agent33101
Agent32101
Agent35101
Agent34101
Agent43101
Agent42101
Agent41101
Agent45101
Agent47101
Agent44101
Agent413011
Agent412011
Agent411011
Agent410011
Agent49011
Agent46011
Agent514101
Agent517101
Agent518101
Agent515101
Agent516101
Agent513011
Agent519011
Agent63101
Agent62101
Agent61101
Agent65101
Agent612101
Agent611101
Agent614101
Agent68101
Agent615101
Agent616101
Agent64101
Agent66101
Agent63101
Agent62101
Agent65101
Agent66101
Agent69011
Agent68011
Agent61011
Agent75101
Agent713011
Agent718011
Agent714011
Agent717011
Agent719011
Agent712011
Agent711011
Agent716011
Agent715011
Agent77011
Agent710011
Agent79011
Agent78011
Agent73011
Agent71011
Agent76011
Agent74011
Agent72011
  • Anonymous's avatar
    Anonymous
    8 years ago

    HI phelms,

     

    You can use below formula to get the total percent with conditions:

    100% / 75% Taget Percent =
    VAR temp =
        SUMMARIZE (
            'Sample',
            [fullname],
            "Pecent", CALCULATE (
                SUM ( 'Sample'[on target] ) / SUM ( 'Sample'[at work] ),
                ALLSELECTED ( 'Sample' ),
                VALUES ( 'Sample'[fullname] ),
                VALUES ( 'Sample'[week] )
            )
        )
    RETURN
        FORMAT (
            COUNTROWS ( FILTER ( temp, [Pecent] = 1 ) )
                / COUNTROWS ( VALUES ( 'Sample'[fullname] ) ),
            "Percent"
        )
            & " / "
            & FORMAT (
                COUNTROWS ( FILTER ( temp, [Pecent] > 0.75 ) )
                    / COUNTROWS ( VALUES ( 'Sample'[fullname] ) ),
                "Percent"
            )
    

     

    Regards,

    Xiaoxin Sheng

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    HI phelms,

     

    You can try to use below measure to calculate on target percent.

     

    Formula:

    On target Percent =
    CALCULATE (
        SUM ( 'Sample'[on target] ) / SUM ( 'Sample'[at work] ),
        ALLSELECTED ( 'Sample' ),
        VALUES ( 'Sample'[fullname] ),
        VALUES ( 'Sample'[week] )
    )
    

     

    Result:

     

    Regards,

    Xiaoxin Sheng

    • phelms's avatar
      phelms
      Frequent Visitor

      Almost there. 

       

      What I want to do, is to count how many agents were on target 100% as a percent of whole (in this example 2/7 = 28.6%), and how many agents were on target at least 75% of the time (3/7 = 42.9%).

       

      Can I do that?

      • Anonymous's avatar
        Anonymous
        Not applicable

        HI phelms,

         

        You can use below formula to get the total percent with conditions:

        100% / 75% Taget Percent =
        VAR temp =
            SUMMARIZE (
                'Sample',
                [fullname],
                "Pecent", CALCULATE (
                    SUM ( 'Sample'[on target] ) / SUM ( 'Sample'[at work] ),
                    ALLSELECTED ( 'Sample' ),
                    VALUES ( 'Sample'[fullname] ),
                    VALUES ( 'Sample'[week] )
                )
            )
        RETURN
            FORMAT (
                COUNTROWS ( FILTER ( temp, [Pecent] = 1 ) )
                    / COUNTROWS ( VALUES ( 'Sample'[fullname] ) ),
                "Percent"
            )
                & " / "
                & FORMAT (
                    COUNTROWS ( FILTER ( temp, [Pecent] > 0.75 ) )
                        / COUNTROWS ( VALUES ( 'Sample'[fullname] ) ),
                    "Percent"
                )
        

         

        Regards,

        Xiaoxin Sheng