ALTERYX INSPIRE | Join us this May for for a multi-day virtual analytics + data science experience like no other! Register Now

Alteryx Designer Discussions

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

how to adding rows with conditions

8 - Asteroid

This table includes the historical item cost with the week of when the cost has been updated.

 For example, the cost in WK1 was $10, and this cost remained the same until WK4 when it increased to $15.

item Cost Week
Apple $      10.01
Apple $      15.04
Apple $      12.07
Apple $         8.010


I want to make this table with full consecutive weeks as below, so the cost in WK 2 and WK3 should be 10.00 as well.

item Cost Week
Apple $       10.01
Apple $       10.02
Apple $       10.03
Apple $       15.04
Apple $       15.05
Apple $       15.06
Apple $       12.07



I have created another table with full yearly weeks from WK1 to WK52... but I can't figure out a way to join these two tables or use a formula to make the cost table be come consecutively.


Also, some data do not star from wk1 or has an ending week as below



Therefore, for the above case, since we are now in WK21, I wish the formula can generate the lines for cost from WK1 - WK21 at $25


As the item cost table update by weekly, I want to make a query keep updating with consecutive week cost.

Thank you

12 - Quasar

Hi @ll1100000


Does this do what you want to accomplish?


1. Use the Generate Rows Tool to create all the weeks.

2. Use the Append Tool to create all combinations of items and weeks.

3. Join to assign the known values to items and weeks.

4. Sort, the forward fill missing cost values using the Multi-Row Tool.

5. Reverse sort, then forward fill the remaining missing cost values that occur before the first known value (your Peaches example).


11 - Bolide

Combination of Generate Rows, Append, Join, Sort, Multi-Row Formula would do the magic!



11 - Bolide

@Philip Just realized you posted a solution while I am working on it :). Hi5 to you. We both have a same thought process!

8 - Asteroid

Hi @Philip

Thank you very much for your helps!!

Love your methods, so geniuses!  



8 - Asteroid

Hi @Philip

When I download your query and it was running successfully.

Then I copied exact query by using Alteryx 10.4 version since this is the one my company is using now, I got the following error message in the Generate Rows tools


Parse error at char (0); unknown variable "allweek"


Could you please advise what's wrong with it?  I just dragged the Generate Rows tools and typed exact what you typed in your query....... because of this error, I even can't run the query to pass the appendent tool.



Thank you.

7 - Meteor

But what if you do not want to start with week one and want to cross year boundaries?  For example, a one year period beginning with the current week?