Meliorainsights.com
  • Home
  • Tableau CRM
  • Field Notes
  • Non-Profits
  • Our Clients
  • About

Meliora Insights, LLC

​Data Cloud | CRM Analytics  (TCRM / Einstein Analytics) Consulting
​meliora - 'for the pursuit of the better'


A blog series distilling quantitative concepts /use-cases in CRM Analytics  (Einstein Analytics).

Picture

more Date Mathy stuff

12/24/2023

0 Comments

 
User Story: User needs to see how oppty pipeline differs between two dates. Step 1 involves creating a recipe to run once daily and snaphost the values of the oppty object.(or oli if need more details).. Step 2. Create a dashboard with 2 dates and render oppty by state using multi datastreams. Code below shows data stream and 2 queries which feed the pipeline snapshot dates.. ie today and 1 year back.

Results qry to calc 1 yr back:
 q= load "zds_completeOpptys_v2";
q = filter q by date('SnapshotStamp_Year', 'SnapshotStamp_Month', 'SnapshotStamp_Day') in ["366 days ago".."365 days ago"];
q=  group q by 'SnapshotStamp';
q = foreach q generate 'SnapshotStamp'  as 'sd', substr('SnapshotStamp',2,10) as 'sd2';q=order q by 'sd' desc;
q=limit q 1;

for today
q = load "zds_completeOpptys_v2";
q = filter q by date('SnapshotStamp_Year', 'SnapshotStamp_Month', 'SnapshotStamp_Day') in ["current day".."current day"];
q=  group q by 'SnapshotStamp';
q = foreach q generate 'SnapshotStamp'  as 'topDay', substr('SnapshotStamp',2,10) as 'topDayStr';
q=limit q 1;

comparos of 2 snap dates
​    "query": "q = load \"zds_completeOpptys_v2\";\nq=filter q by 'Region' !=\"International\";\nq = filter q by !('AccountOwner' in [\"Integration User\",\"Integration User2\"]);\nq1 = filter q by  {{column(timeStampText_4.selection,[\"Snapshot1\"]).asEquality('timeStampText')}};\nq1 = filter q1 by date('CloseDate_Year', 'CloseDate_Month', 'CloseDate_Day') in {{cell(static_2.selection,0,\"Valu\").asString()}};\nq2 = filter q by {{column(timeStampText_5.selection,[\"Snapshot2\"]).asEquality('timeStampText')}};\nq2 = filter q2 by date('CloseDate_Year', 'CloseDate_Month', 'CloseDate_Day') in {{cell(q_FY2_1.selection,0,\"Valu\").asString()}};\nresult = group q1 by '{{column(static_1.selection, [\"Valu\"]).asObject()}}'  full, q2 by '{{column(static_1.selection, [\"Valu\"]).asObject()}}' ;\nresult = foreach result generate coalesce(q1.'{{column(static_1.selection, [\"Valu\"]).asObject()}}', q2.'{{column(static_1.selection, [\"Valu\"]).asObject()}}' ) as '{{column(static_1.selection, [\"Valu\"]).asObject()}}', round(sum(q1.'Amt'),0) as 'Pipeline1 Amt',round(sum(q2.'Amt'), 0) as 'Pipeline2 Amt', round((sum(q1.'Amt')- sum(q2.'Amt')), 0) as 'Difference';\nresult = order result by ('{{column(static_1.selection, [\"Valu\"]).asObject()}}'asc);\nq3 = filter q by {{column(timeStampText_4.selection,[\"Snapshot1\"]).asEquality('timeStampText')}};\nq3 = filter q3 by date('CloseDate_Year', 'CloseDate_Month', 'CloseDate_Day') in {{cell(static_2.selection,0,\"Valu\").asString()}};\nq4 = filter q by {{column(timeStampText_5.selection,[\"Snapshot2\"]).asEquality('timeStampText')}};\nq4 = filter q4 by date('CloseDate_Year', 'CloseDate_Month', 'CloseDate_Day') in {{cell(q_FY2_1.selection,0,\"Valu\").asString()}};\ntot = cogroup q3 by all full,q4 by all;\ntot = foreach tot generate \"--------- TOTALS --------- \" as '{{column(static_1.selection, [\"Valu\"]).asObject()}}' , round(sum(q3.'Amt'),0) as'Pipeline1 Amt', round(sum(q4.'Amt'),0) as 'Pipeline2 Amt', round((sum(q3.'Amt')- sum(q4.'Amt')), 0) as 'Difference';\nfinal =union result, tot;\n",



0 Comments



Leave a Reply.

Site powered by Weebly. Managed by Hostwinds
  • Home
  • Tableau CRM
  • Field Notes
  • Non-Profits
  • Our Clients
  • About