cancel
Showing results for 
Search instead for 
Did you mean: 

how to adding rows with conditions

SOLVED
ll1100000
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

ItemCostWeek
Peach254

 

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

  • Datasets
  • Join
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).

CreateWeeks.png

gnans19
Alteryx Certified Partner

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

 

image.png

gnans19
Alteryx Certified Partner

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

ll1100000
Asteroid

Hi @Philip

Thank you very much for your helps!!

Love your methods, so geniuses!