3 Replies Latest reply on May 30, 2016 2:11 PM by Manjula Raj

# How to calculate the number of correct answer of a user in the segment of 50

I've table history where it has the id, user_id,chart_id and is_correct and other columns. I want to calculate the no of correct_answers of user in the first 50 charts, then from 50 to 100 charts how many corrects answers and same for 150 to 200.

I want something like this:

If WINDOW_MIN( index() >50 and < 1001) then SUM(IF [Is Correct]=TRUE then 1 END)

• ###### 1. Re: How to calculate the number of correct answer of a user in the segment of 50

You might be able to do this by creating two calculated the fields. The first would determine the set of charts based on the [chart id] which I've called [chart_group].

[chart_group]

IF [chart_id] <51 then "1-50"

ELSEIF [chart_id]>50 and < 101 then "50-100"

ELSEIF [chart_id]>100 and < 151 then "101-150"

ELSEIF [chart_id]>150 and < 201 then "150-200"

END

You might be able to just add this dimension to the table to get the result you need, or you could use a LOD expression to do the calculation. I believe it would be something like:

{FIXED [user_id], [chart_group] : SUM(IF [Is Correct]=TRUE THEN 1 END)}

If you could provide a sample dataset I might be able to provide more assistance if this approach doesn't work.

Hope this helps

-Marc

• ###### 2. Re: How to calculate the number of correct answer of a user in the segment of 50

Thanks Turner for you reply.

Chart_id is not sequential to user. User will have random charts.COUNT( Chart_id ) is varies from user to user.

Actually I want to calculate the accuracy for first 50 charts,next 50 to 100 charts, then 100 to 150 and last above150 charts.

No of Correct Answer = SUM(IF [Is Correct]=TRUE then 1 END)

accuracy = (1.0 * [No of Correct Answer] / SUM([Number of Records]) )*100

For example: if User_id 55 has total charts 302. When user completed first 50 charts need to calculate its no of correct answer then accuracy. Then chart count 51 to 100 and so on.

Attached the history table data.Part of this question is answered in the following thread.

• ###### 3. Re: How to calculate the number of correct answer of a user in the segment of 50

Sorry, missed to attached the file in the previous post