I have a database with few tables, ex.:
- users (Id, Name)
- Status (Id, Name)
- log (uniqueId, lead_id, call_date,status_id,user_id, Phone_number)
UniqueId LeadId PhoneId call_date calculateColumn
1 55 12345 12Aug
2 55 12345 25Aug
3 55 12345 5Oct 1
4 111 12345 25Nov
5 111 12345 5Dec
6 111 12345 15 dec 1
- list (lead_id, last_local_call_date,status_id,user_id, Phone_number)
LeadId PhoneId Entry_date
55 12345 1Aug
111 12345 10Nov
Requirement;
RedCall Measure :
i need to do calculation (using case statement) based on entry date and lead_id where (entrydate+20 days) of particular leadId greater than max of call_date of that lead id. If condition is true then 1 else zero .
Make sure for particualr lead_id we have to assign only 1 only onetime.
Like in above case in lead_id 55 both 25 nov and 5 oct satisfy greater than (entrydate+20 days) but we will assign 1 to max of satisfying condition i.e, 5 oct.
so i used this query in dsv.
SELECT
t2.uniqueID,t2.Lead_ID,t2.phone_number,t2.call_date,t1.entry_date,t2.list_id,
t2.length_in_sec,t2.user,t2.status,
CASE WHEN t2.call_date = t3.call_date THEN 1 ELSE 0 END as "RedCalls"
FROM asterisk.vicidial_log t2
Inner join (select entry_date,lead_id from
asterisk.vicidial_list)t1 on t1.lead_ID = t2.lead_ID
LEFT JOIN
( select lead_ID,MAX(call_date) as call_date
from asterisk.vicidial_log
group by lead_ID
)t3 ON t3.lead_ID = t1.lead_ID
AND t3.call_date >= DATE_ADD(t1.entry_date, INTERVAL 22 DAY)
i need more measure based on such condition from this log table when i create measure using named Query in dsv My Query is hanged .
Kindly suggest something me for creating Fact table for my cube in efficient manner.
I am very new to SSAS and your suggestion and opinion will be very useful to me.
i first think i'll create my fact table outside.
i dont know the efficeint manner .
Kindly suggest needful.