Forum Discussion

Junaid11's avatar
Junaid11
Icon for Helper V rankHelper V
3 years ago
Solved

Compare with Monthly and Daily Target

Hello, I have two tables. One table gives detail of Daily and monthly target for each month and category for a user of tasks completed which is given below: Month/Year User Name Daily Target ...
  • v-yanjiang-msft's avatar
    3 years ago

    Hi Junaid11 ,

    According to your description, here's my solution.

    Sample:

    Target table:

    Table:

    Note: Month/Year column in Target table is date type, but MonthYear column in Table is text type.

    Here's my solution, create two measures:

    DailyTargetPercentage =
    VAR _Compelete =
        COUNTROWS ( 'Table' )
    VAR _Target =
        MAXX (
            FILTER (
                'Target',
                EOMONTH ( 'Target'[Month/Year], 0 ) = EOMONTH ( MAX ( 'Table'[Date] ), 0 )
                    && 'Target'[User Name] = MAX ( 'Table'[User] )
                    && 'Target'[Category] = MAX ( 'Table'[Category] )
            ),
            'Target'[Daily Target]
        )
    RETURN
        DIVIDE ( _Compelete, _Target )
    
    MonthlyTargetPercentage =
    VAR _Compelete =
        COUNTROWS ( 'Table' )
    VAR _Target =
        MAXX (
            FILTER (
                'Target',
                EOMONTH ( 'Target'[Month/Year], 0 ) = EOMONTH ( MAX ( 'Table'[Date] ), 0 )
                    && 'Target'[User Name] = MAX ( 'Table'[User] )
                    && 'Target'[Category] = MAX ( 'Table'[Category] )
            ),
            'Target'[Monthly Target]
        )
    RETURN
        DIVIDE ( _Compelete, _Target )
    

    Get the result:

    I attach my sample below for your reference.

     

    Best Regards,
    Community Support Team _ kalyj

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