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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
gunther15
Frequent Visitor

HIt Rate Calculation

Hi,

 

I have a hit range filter of 1 month, 3 months, 6 month, 9 month, and 12 months.  I need to filter out the total trans amount for each one of those to get the hit rate.  I also have the total quoted amount for each month so like January 2020 etc.  So for 1 month I need the 1 month hit range trans amount divided by the quoted amount in that specific month.  For 3 months I would need 1 and 3 Months added together divided by the total quoted amount for that specific month and etc.  What caculations would I needed to be done to get this?

gunther15_0-1665000444419.png

Here is the data for January 2020.

 

Thank you

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @gunther15 ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Add a custom column as below in Power Query Editor

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XY47CgMxDESvYlwvQj/L9iHCHsC4SyBFyMIm9yeyXSxEqBAzjxm1FuM21siEEse+tUjhdry/T1cVURiK+ClMVpbNy/8MVZkNWP0kQqQ/Ihxn2F/3xzn9ipYgjzAqaLbK5Aor4gOuDzhrxQnYBaRcNUOabVyNbQL1ArIQM2gaALI/FHv/AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Hit Rate Range" = _t, #"Total Trans Amount" = _t, #"Total Quoted" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Hit Rate Range", type text}, {"Total Trans Amount", type number}, {"Total Quoted", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Month Range", each if [Hit Rate Range]="" then 0 
else if  Text.Contains ([Hit Rate Range],"or Older") then 999 else  Text.Select([Hit Rate Range],{"0".."9"})),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Month Range", Int64.Type}})
in
    #"Changed Type1"

yingyinr_0-1665047625519.png

2. Create a measure as below:

Hit Rate = 
VAR _selmrange =
    SELECTEDVALUE ( 'Table'[Month Range] )
VAR _sumoftquoted =
    SUM ( 'Table'[Total Quoted] )
VAR _cultramount =
    CALCULATE (
        SUM ( 'Table'[Total Trans Amount] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Month Range] <= _selmrange )
    )
RETURN
    DIVIDE ( _cultramount, _sumoftquoted )

yingyinr_1-1665047683000.png

If the above one can't help you get the desired result, please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi  @gunther15 ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

1. Add a custom column as below in Power Query Editor

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("XY47CgMxDESvYlwvQj/L9iHCHsC4SyBFyMIm9yeyXSxEqBAzjxm1FuM21siEEse+tUjhdry/T1cVURiK+ClMVpbNy/8MVZkNWP0kQqQ/Ihxn2F/3xzn9ipYgjzAqaLbK5Aor4gOuDzhrxQnYBaRcNUOabVyNbQL1ArIQM2gaALI/FHv/AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Hit Rate Range" = _t, #"Total Trans Amount" = _t, #"Total Quoted" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Hit Rate Range", type text}, {"Total Trans Amount", type number}, {"Total Quoted", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Month Range", each if [Hit Rate Range]="" then 0 
else if  Text.Contains ([Hit Rate Range],"or Older") then 999 else  Text.Select([Hit Rate Range],{"0".."9"})),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Month Range", Int64.Type}})
in
    #"Changed Type1"

yingyinr_0-1665047625519.png

2. Create a measure as below:

Hit Rate = 
VAR _selmrange =
    SELECTEDVALUE ( 'Table'[Month Range] )
VAR _sumoftquoted =
    SUM ( 'Table'[Total Quoted] )
VAR _cultramount =
    CALCULATE (
        SUM ( 'Table'[Total Trans Amount] ),
        FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Month Range] <= _selmrange )
    )
RETURN
    DIVIDE ( _cultramount, _sumoftquoted )

yingyinr_1-1665047683000.png

If the above one can't help you get the desired result, please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.