# New to QlikView

Discussion board where members can get started with QlikView.

Contributor II

## Get the latest value based on selected year/month

I have a problem with the following scenario:

I have Transactions table, Employees table and Insurance table (for insurance value), the transaction table contains the transactions that happened on employee families, for example when an employee get married then there is a transaction should be entered to the table and set the wife value 1 instead of 0 and when he get a boy also and so on.

the problem is I want to calculate the insurance cost for childs that calculated by (NO_CHILDS * CHILD_INSURANCE) for march,2011 and there is an employee has 2 records in that month, the first record displayed that he has a new born child, and the second record displays that one of the two children became an adult.

we need to come up with a calculation for the last record which displays 1 child only.

Tags (1)
1 Solution

Accepted Solutions
Contributor II

## Get the latest value based on selected year/month

I have solved it by using this expression

SUM(WIFE_INSURANCE)*firstsortedvalue(NO_WIFES, -DATE)