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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

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
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.