Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Junaid11
Helper V
Helper V

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/YearUser NameDaily TargetMonthly TargetCategory
Nov-22James2342355Service
Nov-22John5675576Asset
Nov-22James2356863Manufacture
Nov-22John6766828Service

 

The second table is giving the details of each day task completed by each user in their respective category.
I want to count the number of task for each day and month from second table and compare them with first table daily and monthly tasks. I want to get the percentage like if as per 2nd table John completed 48 tasks in  Service category so what should be the % achieved for daily similarly for monthly. Second table is below:

TaskUserDateTimeCategory
ABJames11/5/202212:35:00 PMService
BCJohn11/5/20226:39:00 PMManufacture
CDJames12/5/20221:02:00 AMAsset
RGJames13/5/202212:00:00 AMService
YIJohn12/5/20223:45:00 AMService
WRJames11/5/202210:35:00 PMManufacture
UIOJohn11/5/20222:09:00 PMManufacture


Kindly let me knwo should I make data model based on user name?
Please help me understand the DAX function to bemade aling with data model.
Thank you

1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Junaid11 ,

According to your description, here's my solution.

Sample:

Target table:

vkalyjmsft_0-1666772719682.png

Table:

vkalyjmsft_1-1666772741281.png

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:

vkalyjmsft_2-1666772983350.png

vkalyjmsft_3-1666772993671.png

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.

 

View solution in original post

1 REPLY 1
v-yanjiang-msft
Community Support
Community Support

Hi @Junaid11 ,

According to your description, here's my solution.

Sample:

Target table:

vkalyjmsft_0-1666772719682.png

Table:

vkalyjmsft_1-1666772741281.png

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:

vkalyjmsft_2-1666772983350.png

vkalyjmsft_3-1666772993671.png

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.

 

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors