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

Filter and grouping bindings for compact SAQL.

3/3/2021

0 Comments

 
I like the flexibility of the non-compact SAQL, however when it comes to having flexible groupings using bindings, I haven't had much success in using the non-compact form so below is the code for the aggregateflex compact form. Let's say you want a table that shows revenues but you want to create a toggle switch composed of 'region' , 'sales office' and  'country'. One day you want to see revenues by 'region' so table will have 2 columns (region and revenues), other times you want to see it by region and country--ie 3 columns >  region , country and revenue.. and so on. this can be accomplised by creating a query, loading the dataset, creating groups, then tweaking the "grouping" by inserting a binding. Code below has 2 bindings- a string filter for fiscal period and grouping. BOTH are selection bindings. Be aware of the line  "groups": "{{column(static_3.selection,[\"Valu\"]).asObject()}}",

When using the UI, groups will resolve to [], you need to take out the [] so it does not expect a list.



  {
                            "query": {
                                "measures": [
                                    [
                                        "sum",
                                        "GP_IOT__c"
                                    ]
                                ],
                                "groups": "{{column(static_3.selection,[\"Valu\"]).asObject()}}",
                                "filters": [
                                    [
                                        "IoT_Fiscal_Period__c",
                                        [
                                            "{{column(cFiscalPeriod_3.selection,[\"FiscalPeriod\"]).asObject()}}"
                                        ],
                                        "=="
                                    ]
                                ]
                            }
                        },
                        {
                            "query": {
                                "measures": [
                                    [
                                        "count",
                                        "*"
                                    ]
                                ],
                                "formula": "B - A",
                                "groups": "{{column(static_3.selection,[\"Valu\"]).asObject()}}"
                            },
                            "header": "GP$ Delta"
                        },

0 Comments



Leave a Reply.

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