Alteryx Designer Desktop Discussions

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

Dynamic Rank based on two fields

RichardJH
5 - Atom

I am trying to rank a dataset by both CompanyRegNo and the Period. I think my workflow configuration using the Multi-Row Formula is not quite right as it goes 1,2,3,4 etc and resets to 1 when the CompanyRegNo changes. I have attached a sample of the output and the rank I am trying to achieve:

 

CustomerNameCompanyRegNoFinanceLineDescPeriodCompany number plus MetricValueDesiredRank
E P S SITE SOLUTIONS LIMITEDUK07560406Turnover (£)31/03/2019UK07560406Turnover (£)01
E P S SITE SOLUTIONS LIMITEDUK07560406Gross profit (£)31/03/2019UK07560406Gross profit (£)01
E P S SITE SOLUTIONS LIMITEDUK07560406Operating profit/(loss) (£)31/03/2019UK07560406Operating profit/(loss) (£)01
E P S SITE SOLUTIONS LIMITEDUK07560406Profit/(loss) before tax (£)31/03/2019UK07560406Profit/(loss) before tax (£)01
E P S SITE SOLUTIONS LIMITEDUK07560406Net cash at bank/(debt) (£)31/03/2019UK07560406Net cash at bank/(debt) (£)31
E P S SITE SOLUTIONS LIMITEDUK07560406Net worth (£)31/03/2019UK07560406Net worth (£)21
E P S SITE SOLUTIONS LIMITEDUK07560406Total c. assets less c/ liabilities (£)31/03/2019UK07560406Total c. assets less c/ liabilities (£)221
E P S SITE SOLUTIONS LIMITEDUK07560406Current ratio31/03/2019UK07560406Current ratio1.121
E P S SITE SOLUTIONS LIMITEDUK07560406Gearing %31/03/2019UK07560406Gearing %981
E P S SITE SOLUTIONS LIMITEDUK07560406Creditsafe Score31/03/2019UK07560406Creditsafe Score671
E P S SITE SOLUTIONS LIMITEDUK07560406Turnover (£)31/03/2018UK07560406Turnover (£)02
E P S SITE SOLUTIONS LIMITEDUK07560406Gross profit (£)31/03/2018UK07560406Gross profit (£)02
E P S SITE SOLUTIONS LIMITEDUK07560406Operating profit/(loss) (£)31/03/2018UK07560406Operating profit/(loss) (£)02
E P S SITE SOLUTIONS LIMITEDUK07560406Profit/(loss) before tax (£)31/03/2018UK07560406Profit/(loss) before tax (£)02
E P S SITE SOLUTIONS LIMITEDUK07560406Net cash at bank/(debt) (£)31/03/2018UK07560406Net cash at bank/(debt) (£)32
E P S SITE SOLUTIONS LIMITEDUK07560406Net worth (£)31/03/2018UK07560406Net worth (£)52
E P S SITE SOLUTIONS LIMITEDUK07560406Total c. assets less c/ liabilities (£)31/03/2018UK07560406Total c. assets less c/ liabilities (£)122
E P S SITE SOLUTIONS LIMITEDUK07560406Current ratio31/03/2018UK07560406Current ratio1.112
E P S SITE SOLUTIONS LIMITEDUK07560406Gearing %31/03/2018UK07560406Gearing %6.062
E P S SITE SOLUTIONS LIMITEDUK07560406Turnover (£)31/03/2017UK07560406Turnover (£)03
E P S SITE SOLUTIONS LIMITEDUK07560406Gross profit (£)31/03/2017UK07560406Gross profit (£)03
E P S SITE SOLUTIONS LIMITEDUK07560406Operating profit/(loss) (£)31/03/2017UK07560406Operating profit/(loss) (£)03
E P S SITE SOLUTIONS LIMITEDUK07560406Profit/(loss) before tax (£)31/03/2017UK07560406Profit/(loss) before tax (£)03
E P S SITE SOLUTIONS LIMITEDUK07560406Net cash at bank/(debt) (£)31/03/2017UK07560406Net cash at bank/(debt) (£)53
E P S SITE SOLUTIONS LIMITEDUK07560406Net worth (£)31/03/2017UK07560406Net worth (£)563
E P S SITE SOLUTIONS LIMITEDUK07560406Total c. assets less c/ liabilities (£)31/03/2017UK07560406Total c. assets less c/ liabilities (£)3453
E P S SITE SOLUTIONS LIMITEDUK07560406Current ratio31/03/2017UK07560406Current ratio1.123
E P S SITE SOLUTIONS LIMITEDUK07560406Gearing %31/03/2017UK07560406Gearing %03
ADVENTURE LEISURE LIMITEDUK01495746Turnover (£)31/12/2020UK01495746Turnover (£)121
ADVENTURE LEISURE LIMITEDUK01495746Gross profit (£)31/12/2020UK01495746Gross profit (£)131
ADVENTURE LEISURE LIMITEDUK01495746Operating profit/(loss) (£)31/12/2020UK01495746Operating profit/(loss) (£)141
ADVENTURE LEISURE LIMITEDUK01495746Profit/(loss) before tax (£)31/12/2020UK01495746Profit/(loss) before tax (£)151
ADVENTURE LEISURE LIMITEDUK01495746Net cash at bank/(debt) (£)31/12/2020UK01495746Net cash at bank/(debt) (£)161
ADVENTURE LEISURE LIMITEDUK01495746Net worth (£)31/12/2020UK01495746Net worth (£)211
ADVENTURE LEISURE LIMITEDUK01495746Total c. assets less c/ liabilities (£)31/12/2020UK01495746Total c. assets less c/ liabilities (£)221
ADVENTURE LEISURE LIMITEDUK01495746Current ratio31/12/2020UK01495746Current ratio0.1031991
ADVENTURE LEISURE LIMITEDUK01495746Gearing %31/12/2020UK01495746Gearing %01
ADVENTURE LEISURE LIMITEDUK01495746Turnover (£)31/12/2019UK01495746Turnover (£)331
ADVENTURE LEISURE LIMITEDUK01495746Gross profit (£)31/12/2019UK01495746Gross profit (£)342
ADVENTURE LEISURE LIMITEDUK01495746Operating profit/(loss) (£)31/12/2019UK01495746Operating profit/(loss) (£)3452
ADVENTURE LEISURE LIMITEDUK01495746Profit/(loss) before tax (£)31/12/2019UK01495746Profit/(loss) before tax (£)4352
ADVENTURE LEISURE LIMITEDUK01495746Net cash at bank/(debt) (£)31/12/2019UK01495746Net cash at bank/(debt) (£)562
ADVENTURE LEISURE LIMITEDUK01495746Net worth (£)31/12/2019UK01495746Net worth (£)4652
ADVENTURE LEISURE LIMITEDUK01495746Total c. assets less c/ liabilities (£)31/12/2019UK01495746Total c. assets less c/ liabilities (£)52
ADVENTURE LEISURE LIMITEDUK01495746Current ratio31/12/2019UK01495746Current ratio0.0944842
ADVENTURE LEISURE LIMITEDUK01495746Gearing %31/12/2019UK01495746Gearing %02
ADVENTURE LEISURE LIMITEDUK01495746Turnover (£)31/12/2018UK01495746Turnover (£)3452
ADVENTURE LEISURE LIMITEDUK01495746Gross profit (£)31/12/2018UK01495746Gross profit (£)7653
ADVENTURE LEISURE LIMITEDUK01495746Operating profit/(loss) (£)31/12/2018UK01495746Operating profit/(loss) (£)7653
ADVENTURE LEISURE LIMITEDUK01495746Profit/(loss) before tax (£)31/12/2018UK01495746Profit/(loss) before tax (£)6543
ADVENTURE LEISURE LIMITEDUK01495746Net cash at bank/(debt) (£)31/12/2018UK01495746Net cash at bank/(debt) (£)6753
ADVENTURE LEISURE LIMITEDUK01495746Net worth (£)31/12/2018UK01495746Net worth (£)6753
ADVENTURE LEISURE LIMITEDUK01495746Total c. assets less c/ liabilities (£)31/12/2018UK01495746Total c. assets less c/ liabilities (£)5643
ADVENTURE LEISURE LIMITEDUK01495746Current ratio31/12/2018UK01495746Current ratio0.0866353
ADVENTURE LEISURE LIMITEDUK01495746Gearing %31/12/2018UK01495746Gearing %03
ADVENTURE LEISURE LIMITEDUK01495746Creditsafe Score31/12/2020UK01495746Creditsafe Score1001
3 REPLIES 3
patrick_digan
17 - Castor
17 - Castor

@RichardJH I would sort your data, first by CompanyRegNo, and then by period. Then in your multi-row formula I would first group by CompanyRegNo. Then your formula would be something like: [Row-1:DesiredRank]+If [Row-1:Period]=[Period] then 0 else 1 endif. 

 

By grouping by CompanyRegNo, that will reset it for each Company. The formula takes the prior rank and adds 1 if it's a different date or 0 if it's the same date. That should get your desired rank.

 

You could also use the tile tool after you've sorted your data, set it to unique value, unique column is Period and group by columns CompanyRegNo. It will output 2 fields, and TileNum should be the same as your desired rank.

 

 

Hope that helps!

atcodedog05
22 - Nova
22 - Nova

I generally used to go with formula like below

If [Row-1:Period]=[Period] then [Row-1:DesiredRank] else [Row-1:DesiredRank] +1 endif

 

But this formula is definitely a different way we can look at it

[Row-1:DesiredRank]+If [Row-1:Period]=[Period] then 0 else 1 endif

 

Thank you for the knowledge share and exposure @patrick_digan 🙂

RichardJH
5 - Atom

Just the formula I needed, thank you @patrick_digan. Sorting the period descending gets the latest period to be a ranking of 1, which I'll use for my work. Thank you once again.

Labels