How to give an alias to an aggregation on a column?

Hi all,

 

I am using the Domo Api, and I need to group by the request on the sum of a column, just like below:

 

stringQuery= '/data/v1/dataSetAlias?fields=alias1,alias2&sum=alias3'
+ '&groupby=alias1,alias2,"sum=alias3"
+ '&orderby="sum=alias3" descending';

domo.get(stringQuery)
...

 

For now, i dont know a way to give an alias to "sum=alias3" so I can groupp by on it,
the only way that works is like below (not appliying the sum on the grouping or the ordering):

 

stringQuery= '/data/v1/dataSetAlias?fields=alias1,alias2&sum=alias3'
+ '&groupby=alias1,alias2,"alias3"
+ '&orderby="alias3" descending';

domo.get(stringQuery)
...

 But this doesn't give me the result I am waiting for.

 

Can you help me with this?

 

Thanks

 

Hiba

Comments

  • KaLin
    KaLin Member

    Can anyone help with this request?

  • jake-galbraith
    jake-galbraith Domo Employee

    Have you tried :

     

    stringQuery= '/data/v1/dataSetAlias?fields=alias1,alias2,alias3'
    + '&groupby=alias1,alias2,"sum=alias3"
    + '&orderby="alias3" descending';

    When a groupby is present, you only want to specify the aggregation operator inside the group by clause. Let me know how this goes. 

    Jake Galbraith
  • Hi Jake,

     

    Thanks for your answer.
    But this is not working. The aggregation in the groupBy doesn't work.

    When I do this:

    stringQuery= '/data/v1/dataSetAlias?fields=alias1,alias2,alias3'
    + '&groupby=alias1,alias2,sum=alias3'
    + '&orderby=alias3 descending';

    I have this error on the browser console:

    Failed to load resource: the server responded with a status of 406 (Not Acceptable)
    domo.js:5 Uncaught (in promise) Error: Not Acceptable
    at XMLHttpRequest.o.onload (domo.js:5)

    Any ideas? I really need to have the alias3 aggregated and the result sorted with it.

    Thanks,

    Hiba

  • jake-galbraith
    jake-galbraith Domo Employee

    Yes my mistake, this should hopefully do the trick. You just state the aggregation prior to the groupby. 

     

    stringQuery= '/data/v1/dataSetAlias?fields=alias1,alias2,alias3'
    + '&sum=alias3&groupby=alias1,alias2,alias3'
    + '&orderby=alias3 descending';

     

    Jake Galbraith
  • Hi Jake,

     

    Still not working.

    Grouping by alias3 and not the aggregation of alias3 is splitting the result. And then I am having duplicated objects in place of grouping them and giving the total on alias3.

    Help me please resolve this.

     

    Thanks.

     

    Hiba

  • jake-galbraith
    jake-galbraith Domo Employee

    Please do, let's get this working for you. You can send me a private message by clicking on my profile name and then on the right side click on send this user a private message.

    Jake Galbraith
This discussion has been closed.