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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

DAX - Calculating a Hit Rate

I have a requirement to calculate a hit rate = (number of times the actual value >=target)/(total number of hit/misses over weeks (max can only be 52weeks)).

 

Currently the Hit Rate is calculated at Sales Org level in excel. However the data structure has changed(Please see the screenshot attached for the sample data structure).

 

I want to be able to see the hit-rate at Sales Org level or for a Specific category for the current week.

 

Example. Currently we are in week 40 of the year. We have been able to hit the traget 36 times(weeks) at Sales Org level then.. Hit Rate =36/40.

 

How can this be realised in Power BI for both Sales Org and Category. The data structure can be changed to suit the solution. Thanks in advance

 

Sales Org.Category MonthWeek NumberTargetRecordedHit/miss
Sales Org 1Category A110.900.961
Sales Org 1Category A120.900.971
Sales Org 1Category A130.900.880
Sales Org 1Category A140.900.991
Sales Org 1Category B210.951.001
Sales Org 1Category B220.950.940
Sales Org 1Category B230.950.951
Sales Org 1Category B240.951.001
Sales Org 2Category A110.900.961
Sales Org 2Category A120.900.971
Sales Org 2Category A130.900.880
Sales Org 2Category A140.900.991
Sales Org 2Category B210.951.001
Sales Org 2Category B220.950.940
Sales Org 2Category B230.950.951
Sales Org 2Category B240.951.001

 

5 REPLIES 5
luxpbi
Helper V
Helper V

Hi @Anonymous,

 

Is your data structure as you show in the image, have you done changes manually ? 
If so, what is the native structure of your data? 

If you don't, you can solve it using 3 simple measures or combine them into one. 

Measure 1:

Hit = SUM( Table3[Hit] ) 

Measure 2:

Total attempts = COUNT( Table3[Hit] ) 

Measure 3:

Hit Rate = DIVIDE( [Hits] ; [Total attempts] ) 

Combined :

Combined =
VAR Hits = SUM( Table3[Hit] )
VAR TotalAt = COUNT( Table3[Hit] )
RETURN
DIVIDE( Hits ; TotalAt )

Then you just need to put a slicer filter with the weeks. You can use a simple filter to see only one week in particular or you can chosse the less than or equal to to see the accumulate. 

 

Hope that helps. 

 

Regards,

 

Anonymous
Not applicable

@luxpbi thanks for the response however this does not give correct answers. It does not account for the weeeks. 

 

Please see below the structure of my expected result:

Sales Org.CategoryWeek Hit Rate
Sales Org 1Category A410.95
Sales Org 1Category B411.00
Sales Org 2Category A410.8
Sales Org 2Category B410.67
Anonymous
Not applicable

My data source is excel. I have added a UID by concatinating the Salesorg and Catergory.

Using the vlookup: =SUMIF(B:B;K2;I:I)/COUNTIF(B:B;K2)

 

My new data looks like:

 

UIDSales Org.Category MonthWeek NumberTargetRecordedHit/miss
Sales Org 1Category ASales Org 1Category A110.900.961
Sales Org 1Category ASales Org 1Category A120.900.971
Sales Org 1Category ASales Org 1Category A130.900.880
Sales Org 1Category ASales Org 1Category A140.900.991
Sales Org 1Category BSales Org 1Category B210.951.001
Sales Org 1Category BSales Org 1Category B220.950.940
Sales Org 1Category BSales Org 1Category B230.950.951
Sales Org 1Category BSales Org 1Category B240.951.001
Sales Org 2Category ASales Org 2Category A110.900.961
Sales Org 2Category ASales Org 2Category A120.900.971
Sales Org 2Category ASales Org 2Category A130.900.880
Sales Org 2Category ASales Org 2Category A140.900.991
Sales Org 2Category BSales Org 2Category B210.951.001
Sales Org 2Category BSales Org 2Category B220.950.940
Sales Org 2Category BSales Org 2Category B230.950.951
Sales Org 2Category BSales Org 2Category B240.951.001

 

Expected result:

UIDSales Org.CategoryWeek Hit Rate
Sales Org 1Category ASales Org 1Category A410,75
Sales Org 1Category BSales Org 1Category B410,75
Sales Org 2Category ASales Org 2Category A410,75
Sales Org 2Category BSales Org 2Category B410,75

You can try creating measures as below:

 

Attempts # = COUNTROWS('Table')

Week = WEEKNUM(TODAY())

Hit Rate =
DIVIDE (
    CALCULATE (
        [Attempts #],
        FILTER (
            SUMMARIZE ( 'Table', 'Table'[Recorded], 'Table'[Target] ),
            'Table'[Recorded] >= 'Table'[Target]
        )
    ),
    [Attempts #]
)

Greg_Deckler
Super User
Super User

This seems straight-forward. Can you post that data in text format? Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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