Metric Type: F1(X) / F2(Y)

Modified on Mon, 10 Jul, 2023 at 8:44 AM

Description

This metric types calculates the average or percentage of two metrics. Imagine if you need to take an average of two different total durations. Another scenario would be a percentage of one metric value over another.

Examples

  1. What percentage of distinct patients were prescribed medication?
  2. What is the avg. duration of patients seen over Phone vs. Video?

Details

Imagine the following data that describes patient encounters in each row of data.

Patient IDDateDurationEncounter Type
103/19/2210Video
204/25/2220Video
104/26/2215Phone
306/09/2310Phone


Here, if we want to calculate the percentage of patients that had Phone Encounters, the formula will look something like this:


Distinct Number of Patients who had Phone Encounter / Distinct Number of Patients = 2 / 3 = 0.66


Here, the "Distinct Number of Patients Who had Phone Encounter" is the first metric, lets call it F1 and "Distinct Number of Patients" is F2. 


Further lets write out F1 and F2 for the above example.

F2 = DistinctCount ( Patient ID) 

F1 = DistinctCount ( Patient ID) with filter "Encounter Type = Phone"


This can be accomplished by filling out the metric fields with the following examples. 


Technical Specs

This metric type provides the ability to choose different function types for numeration or denominator and further calculate average or percentage of the two metrics. It also provides the flexibility to 


SQL Query

This metric type uses the following query. This metric type uses two sub queries to calculate the metrics in numerator and denominator and then take the average. Further, a formula option is provided in case further manipulation is needed on the result e.g. "Multiply by 100" to convert division to percentage. 

SELECT num_table.result / denom_table.result {formula} as result 
FROM (SELECT {f1}{Numerator Field} as result 
      FROM {TRP Table Name} 
      WHERE {Numerator Filters}) as num_table 
INNER JOIN (SELECT {F2}{Denominator Field} as result 
      FROM {TRP Table Name} 
      WHERE {Denominoator Filters}) as denom_table

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article