hi all! i'm not sure where to post this. i hope i'm posting at the right section.

previously i use formula as below;

Dim total1 As Label = CType(e.Item.FindControl("total1"), Label)
        total1.Text = e.Item.DataItem("receivable").ToString * 365 / e.Item.DataItem("revenue").ToString

note that the 'receivable' and 'revenue' are taken from database(mysql)

however,if the formula of a calculation involve data for current year divide by data from previous year, how should i implement it? for example;

revenue from current year * 365 / revenue from previous year

Try converting data from database into soem number type, I will show you an example converting to decimal:

Dim total1 As Label = DirectCast(e.Item.FindControl("total1"), Label)
total1.Text = Convert.ToDecimal(e.Item.DataItem("receivable")) * 365 / Convert.ToDecimal(e.Item.DataItem("revenue"))

Remember, Math operations are only possible over math values (no strings involved).

no, no. the coding that i have posted already working fine but it is for other function. i simply paste it here as an example of the formula. i just want to know how to get the data (the same field) with different year. i want to get the company's revenue for current and previous year.

my friend have found the solution.

SELECT cur.alert_id, cur.year_id,cur.period_id, cur.alert_value, prev.alert_id AS alert, 
prev.year_id AS prev_year_id,prev.period_id AS prev_period_id, prev.alert_value AS prev_alert_value
FROM company_alert AS cur
LEFT OUTER JOIN company_alert AS PREV ON cur.year_id = prev.year_id + 1 
WHERE cur.alert_id = "DSO" AND prev.alert_id = "DSO"
ORDER BY year_id
This question has already been answered. Start a new discussion instead.