Hello I have 2 calculated columns in a power pivot model (key and week), Key consists of a store number and a demonstration product that is not operational in store. Week is when a store was visited by a sales rep.
I am looking to create another calculated column- Number of weeks not working, which counts how many weeks the key has appeared in the data. An example is below. The only catch is I am trying to reset the counter if the key does not appear in the previous week, an example of this is Key 29-product 1 in week 5 (highlighted red). This reverts back to a zero count for weeks not operational as Key 29-product 1 did not appear in week 4.
Any help would be appreciated, thanks.
[TABLE="width: 344"]
<tbody>[TR]
[TD]key
[/TD]
[TD]Week
[/TD]
[TD]*Number of weeks not working[/TD]
[/TR]
[TR]
[TD]29-product1[/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]29-product2[/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]41-product1[/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]55-product1[/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]29-product1[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]29-product2[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]41-product1[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]55-product1[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]29-product1[/TD]
[TD]3[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]29-product2[/TD]
[TD]3[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]41-product1[/TD]
[TD]3[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]55-product1[/TD]
[TD]3[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]29-product1[/TD]
[TD]4[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]29-product2[/TD]
[TD]4[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]41-product1[/TD]
[TD]4[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]55-product1[/TD]
[TD]4[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]29-product2[/TD]
[TD]5[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]41-product1[/TD]
[TD]5[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]55-product1[/TD]
[TD]5[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]29-product1
[/TD]
[TD]5
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]29-product2[/TD]
[TD]5[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]41-product1[/TD]
[TD]5[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]55-product1[/TD]
[TD]5[/TD]
[TD]5[/TD]
[/TR]
</tbody>[/TABLE]
I am looking to create another calculated column- Number of weeks not working, which counts how many weeks the key has appeared in the data. An example is below. The only catch is I am trying to reset the counter if the key does not appear in the previous week, an example of this is Key 29-product 1 in week 5 (highlighted red). This reverts back to a zero count for weeks not operational as Key 29-product 1 did not appear in week 4.
Any help would be appreciated, thanks.
[TABLE="width: 344"]
<tbody>[TR]
[TD]key
[/TD]
[TD]Week
[/TD]
[TD]*Number of weeks not working[/TD]
[/TR]
[TR]
[TD]29-product1[/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]29-product2[/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]41-product1[/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]55-product1[/TD]
[TD]1[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]29-product1[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]29-product2[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]41-product1[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]55-product1[/TD]
[TD]2[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]29-product1[/TD]
[TD]3[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]29-product2[/TD]
[TD]3[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]41-product1[/TD]
[TD]3[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]55-product1[/TD]
[TD]3[/TD]
[TD]2[/TD]
[/TR]
[TR]
[TD]29-product1[/TD]
[TD]4[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]29-product2[/TD]
[TD]4[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]41-product1[/TD]
[TD]4[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]55-product1[/TD]
[TD]4[/TD]
[TD]3[/TD]
[/TR]
[TR]
[TD]29-product2[/TD]
[TD]5[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]41-product1[/TD]
[TD]5[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]55-product1[/TD]
[TD]5[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]29-product1
[/TD]
[TD]5
[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]29-product2[/TD]
[TD]5[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]41-product1[/TD]
[TD]5[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]55-product1[/TD]
[TD]5[/TD]
[TD]5[/TD]
[/TR]
</tbody>[/TABLE]