How to Add Aggregate function as custom function.

Abhijeet Teli shared this question 7 years ago
Answered

Hi Team,


We have crated a custom function at Database layer and now it needs to go in Predefined Section.

But this is an Aggregate function. so expectation is when i add this function in report all other fields should append in Group By clause, Just like Standard aggregate function.

Can you please let me know how to achieve it.


Thanks,

Abhijeet

Replies (9)

photo
1

Hi Abhijeet,

How you define the aggregation in the custom function depends highly on what you are trying to achieve. Typically setting the where clause to the exact statement as the SQL SELECT function will work, but occasionally, you need to aggregate by other dimensions. One note is that this will require that dimension to also be in the report, to force Yellowfin to employ a GROUP BY clause.

This article is a good example of implementing a function with an odd group by clause that might give you ideas:

http://community.yellowfin.bi/topic/aggregate-a-text-column

If this does not work, it would be helpful if you could elaborate on what exactly you are trying to achieve here.

Regards,

Nathan

photo
1

Hi Nathan,

I have similar use case and i understood what you are suggesting i tried similar workaround not exact same. But this just a workaround you can only use one Dimension against the Languages field.

what if you need to add Region dimension in to the report. It may not work i suppose.


So what i am expecting,

when i define any custom function and if it is aggregate function then There should be some flag like AGGREGATE=TRUE, When this function used in Report query generation should include all other dimension field in Group by Clause, Just like Standard Count or SUM function.


In case if we don't have any other way than suggested workaround, Then we can take this as Enhancement Request.


Thanks,

Abhijeet

photo
1

Hi Abhijeet,


I agree that these aggregations should work more naturally within Yellowfin than they currently do, but am not sure what this would require from a coding standpoint to implement, so am hesitant to make any garuntees that it will be possible.


I am going to convert this question to an idea, and once the product team has had a chance to review this we should have a better idea if this is something that can happen.


Let me know if there is anything I can do to help on this in the meantime.


Regards,

Nathan

photo
1

Hi Nathan,

This sounds good. Just keep me posted about discussion with Product Team,

I tricked system to work it around so nothing required at this point.


Thanks for your help.


Cheers,

Abhijeet

photo
1

Hi Abhijeet,


Seems like you're talking about pre-defined templates used in calc fields, which all come from the custom-functions.xml file.

If so, then this should be possible already.


You need to include the <groupby> and<aggregate> elements as part of the function definition, as described onthe wiki here


Please let me know if I'm missing something.


Regards,

David

photo
1

Hi Abhijeet,

Based on the feedback we received, I was able to get the custom function in my example working without employing the work around (I have edited teh article I linked you). Here is an article created from the feedback:

http://community.yellowfin.bi/knowledge-base/article/aggregation-vs-group-by-in-custom-functions

If you are still facing issues, can you send me a copy of your custom function XML?

Regards,

Nathan

photo
1

Abhijeet, Can you confirm if the answer below helped answer your question? Thanks

photo
1

Yes Lee,

This workaround has resolved my use case,

Thanks Nathan, Please mark this request as completed

Thanks,

Abhijeet

photo
1

Glad to hear it Abhijeet, I will close this case now.

Leave a Comment
 
Attach a file