community
cancel
Showing results for 
Search instead for 
Did you mean: 

Alteryx designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
SOLVED

How to do groupby with having clause in Alteryx

I'm trying to build a workflow which would do the below operation in Alteryx? Should I use In-Db or any other tool like summarize tool to do group by and having. I was able to do the group by using summarize tool, but not able to perform having.  

 

select memberId, procedureCode
from claims
group by memberId, procedureCode
having count(distinct year(ServiceDate) * 100 + month(ServiceDate)) > 4;
Highlighted
Alteryx Certified Partner

Hi @monish_chandra 

 

I recommend you to break up your SQL statement in parts.


First, create a field using Formula Tool to do this:

year(ServiceDate) * 100 + month(ServiceDate)

then, use Summarize Tool to Group By (Member Code, Procedure Code) and Count your Formula Field previously created.

 

Then, after all, filter your Count (Formula Field) > 4.

 

You should have your final result.

 

Cheers,

Labels