# How we can compare two categories in one insight?

Hi,
I have one senario where i need to compare the course with maximum duration base on higest completion rate
for example:
course1: duration 30 days and completion rate is 90%
course2: duration 45days and completion rate is 100%
here i have to show the duration 45days of course 2

can you please help me how we can write expressions for comparing two categories and metrics in insight?

Can you explain how you are getting these calculations?

Is it a top ranked?

If so could you limit it to just one based on the completion rate?

Hi max,
yes first we need to take top ranked courses based on completion rate
then we have to show only respective completion duration in insight.
Note:
we need to consider multiple senarios

1. when completion rate is null how we can handle
2. when completion rate is equal for top 3 campaigns how we can handle

If it’s top ranked why can’t you just limit it to one? Is that because of the scenarios?

For the scenarios:

1. What do you want to have happen if it’s null? Filter it out?
2. That will be tricky. In an insight for a top ranked calculation you will only be able to display the amount of categories that you say in the calculation. You might look at making three calculations (if your max will be three) and then writing if statements in the insight that check to see how many are equal at the top. Three calculations would be Top, Top2, Top3 where Top one only has the top one, two top two, and three top three.

IF Top3.items[2].metricValue.value=Top.items[0].metricValue.value

Display all three calculation.

IF Top3.items[1].metricValue.value=Top3.items[0].metricValue.value AND Top3.items[2].metricValue.value<>Top3.items[0].metricValue.value

Display Top 2

IF Top3.items[0].metricValue.value<>Top3.items[1].metricValue.value

Display Top 1

Hi Max,
please find the calculated feilds
completions=sum(case when completiondate is not null then 1 else 0 end)–where completiondate is not null
Assigned Learners=count(userid)
completionrate=completions/assigned learners
duration=date_diff(day,startdate,closedate)
please help me to create insight which shows the duration of course whose completion rate is high

You would add those calculated fields as values and the courses as groups and then do what I did in my previous answer.