Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Dynamic calculating last fifth month data and coming month data

adarsh2608
8 - Asteroid

Hello

 

in report when I run this month which shows last 5 months data from Jan to may  , next month when I run the workflow it should show last 5 months data but the last fifth month column will be sum of feb+ jan month values, similarly I July when I'm running it should show last fifth month column will be sum of Feb+March+Jan remaining will be same as last 4 months from the current month .  fifth month column  calculation with previous month starts on  MAY and reset on next year May.

sample o/p in current month

GroupJan (2022)Feb(2022)March(2022)April(2022)May(2022)
data111111
data211111
data311111
data311111
data411111

sample o/p when run it on next month

 

GroupJan - Feb (2022)MarchAprilMayJune
Data121111
Data221111
Data321111
Data421111
8 REPLIES 8
IraWatt
17 - Castor
17 - Castor

Hey @adarsh2608,

Here's an example of how I would do this:

IraWatt_3-1653750425254.png

 

Not sure what number you would want in the next month so I just put 1. Can change it here:

IraWatt_2-1653750366995.png

Any questions or issues please ask :)
HTH!
Ira

binuacs
21 - Polaris

@adarsh2608 One way of doing with this with the help of dynamic select tool..

 

The first part (selecting the last 5 months) can be achieved by using the dynamic select tool. You need to adjust the formula in the dynamic tool

The second part is tricky , you need to adjust the code inside the dynamic select tool. Attaching a sample workflow for your reference

binuacs_0-1653856493079.png

 

IraWatt
17 - Castor
17 - Castor

Awesome solution @binuacs, I need to start thinking about using the dynamic select more !

adarsh2608
8 - Asteroid

Hello @binuacs ,

Thank you so much for the response .

 

Consider May as the beginning of the year . When i run the workflow on this month we get last 4 months and current month data as in column there is no calculation of previous month is required. But  when i'm running the workflow on June , the 1st column which was jan in previous month will calculate with the previous month which would be jan + feb . this calculation of 1st column adding with previous month until when in the month of april 2023  and when i'm running this workflow on the April 2023 the first coulmn will be sum (jan +feb+march+apr+may+jun+july+aug+sep+oct+nov+dec)

let me give sample expected o/p of 1st coulmn in each month when i'm running

Month when i'm running workflow1st column2nd column3rd column4th column5th column
Mayjanfebmaraprmay
Junejan+febmaraprilmayjune
Julyjan+feb+maraprilmayjunejuly
Augjan+feb+mar+aprmayjunejulyAug
Sepjan+feb+mar+apr+mayjunejulyAugSep
OCTjan+feb+mar+apr+may+junejulyAugSepOct
NOVjan+feb+mar+apr+may+june+julyAugSepOctnov
DECjan+feb+mar+apr+may+june+july+AugSepOctnovDec
JANjan+feb+mar+apr+may+june+july +aug+SepOctnovDecJan
FEBjan+feb+mar+apr+may+june+july +aug+sep+OctnovDecJanFeb
MARjan+feb+mar+apr+may+june+july +aug+sep+oct+NovDecJanFebMar
APRL jan+feb+mar+apr+may+june+july +aug+sep+oct+nov+DecJanFebMarApril

 

I can share you the sample workflow , i was building if you able to help with a formula which can dynamically add the month

 

if you can help me it would be wonderful, as this is 1st time i'm building with alteryx

 

 

 

binuacs
21 - Polaris

@adarsh2608 It is required more logical updates. I will update the workflow and let you know 

binuacs
21 - Polaris

@adarsh2608 I have updated the dynamic select to pick the dates dynamically as you mentioned in the above example. The workflow is working fine with my sample file. Please try with your input file and let me know if you see any issues. Please note that inorder to get correct result you need to have data on all the months. if any of the month is missing then you will not get the correct result as the dynamic select fields based on the current month. For example the month of June the fields 4-7th picked for processing and rest of the fields will get added into the other dynamic select tool ie Feb and Jan. 

 

[FieldNumber] = toNumber(DateTimeFormat(DateTimeToday(),'%m')) + 1 //June
OR
[FieldNumber] = toNumber(DateTimeFormat(DateTimeToday(),'%m')) + 0 // May
OR
[FieldNumber] = toNumber(DateTimeFormat(DateTimeToday(),'%m')) - 1 // Apr
OR
[FieldNumber] = toNumber(DateTimeFormat(DateTimeToday(),'%m')) - 2 // Mar
OR
[FieldNumber] = 1

 

binuacs_0-1654064592399.png

 

adarsh2608
8 - Asteroid

@binuacs ,

Thank you for the post, after some changes it worked

binuacs
21 - Polaris

@adarsh2608 I’m glad it worked for you. The requirement was a tricky one and it took some days to workout the logic

Labels