Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

(More) CountIfs type questions

JKirstine
6 - Meteoroid

I've been through various discussions on recreating something akin to the the Excel CountIfs function, but have been struggling for 2 days.

 

Basically, I need have a row be able to count any previous rows (it will be previous by default) that match certain criteria

So, for a given row, as long as its type <> "Online", I want to count records/rows where Cust ID = Cust ID, Type DOES = Online in a previous record, and the Purch date of the row to be counted is between the purchase date the row in question and 30 days prior. 

 

In the data below, the later occurrences of CustIDs 199003 and 135833 (I tried to bold type) would each show a count of 1 (assumedly in a new column so i can flag it later), as they each are <>Online, but there is row with a matching CustID, where Type = Online, and was within the previous 30 days. 

 

 

Purch Date APPPurch Date-1Purch Date less 30Purchase#TypeCustID
6/30/20216/29/20215/30/20212260787Online199003
7/1/20216/30/20216/1/20212153512Online135833
7/21/20217/20/20216/21/20212575005Shop2146651
7/21/20217/20/20216/21/20212871696Shop1190452
7/21/20217/20/20216/21/20212834699Shop1183225
7/21/20217/20/20216/21/20212934265Shop1151681
7/21/20217/20/20216/21/20212807218Shop2113738
7/21/20217/20/20216/21/20212967201Shop2127026
7/21/20217/20/20216/21/20212487600Shop2199003
7/21/20217/20/20216/21/20212693672Shop2160585
7/21/20217/20/20216/21/20212058022Online177808
7/21/20217/20/20216/21/20212866540Online111339
7/21/20217/20/20216/21/20212745257Shop1135833
7/21/20217/20/20216/21/20212602772Shop1116841
7/21/20217/20/20216/21/20212899620Shop1155846
5 REPLIES 5
JKirstine
6 - Meteoroid

I think solved my issue, at least in a proof of concept. If it works, I'll post the solution

PhilipMannering
16 - Nebula
16 - Nebula

This was not trivial, especially as batch macros are not my strong point. But may have solved it.

 

See attached,

PhilipMannering_0-1639601857344.png

 

With batch macro,

PhilipMannering_1-1639601903953.png

 

 

FlorianC
Alteryx
Alteryx

Hi @JKirstine,

 

In order to replicate the COUNTIF formula from Excel, I would recommend using the multi-row formula tool. You can easily group by customer ID and look at the values from the previous rows to determine whether the purchase was made online and within 30 days.

 

Please find attached an example workflow demonstrating how to to this.

 

Example workflowExample workflowWorkflow resultsWorkflow results

Florian Carrier
Strategic Solution Consultant
Alteryx
mceleavey
17 - Castor
17 - Castor

@JKirstine ,

 

I did this with a simple multi-row formula.

 

mceleavey_0-1639602536381.png

 

 

Hope this helps,

 

M.



Bulien

JKirstine
6 - Meteoroid

Thanks to everyone who provided a solution. I will look at the multi-row formula.

 

I was able to use a Filter + a Join to get the records I was eventually after, even though I didn't get the flag I was looking for as part of the original solution i had in mind (really need to stop thinking in Excel....LOL). I did make one change from the request in that I used a 14 day window via a new variable rather than the 30 day window I originally talked about. But, it does work and gives me what I need. This is just the proof of concept workflow, but in applying it to my larger dataset and regression testing, it was dead on.

 

Phillip - I will take a look at your solution as I have never attempted Alteryx macros before. This might be a good lesson for me. 

 

Have to say, I love this tool!

 

JKirstine_1-1639670905470.png

 

 

Labels