Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all -
As the title explains, I am looking for a way to auto increment the new row value with the previous row value.
I've got a dimension (MOVIE_VIDEO_NUMBER) that already has data - 1, 2, 3, 4, 5, 6 and 7.
The idea is when a user adds a new row of data (using vizlibs writeback table) I want to auto generate by taking the previous MOVIE_VIDEO_NUMBER and adding 1 to it. Taking my example above, the next row of data created would automatically have an 8, the next would be 9, and so forth.
I've tried playing with the peek and previous function but not grabbing the value I want. I'm sure there is a simpler method and wanted to reach out here.
Thanks.
Hi Rooski,
Nice that you are working with the Vizlib Writeback. I think working with Previous() is the way to go.
Writeback give you a timestamp for the entered value. So you script should be something like this:
WritebackTable:
Load
*, // all your data, but can't be a star because you are using the same [YourIncrementField] field
IF( Trim( [YourIncrementField] ) & '' = '',
Peek( Previous( [YourIncrementField] ) ) + 1,
[YourIncrementField]
) as [YourIncrementField]
Resident [YourSource]
Order by [WriteBackTimeStamp] asc
;
Peek() & Previous() can sometimes give you some headaches, but fits your solution.
Jordy
Climber
Hey JordyWegman thanks for dropping in. I am assuming this script would go under the first script of the injected writeback provided by the wizard? This would be before the load where vizlib converts all of your fields into varchar since it converts it all to a string. I've attached my qvf if that helps. I was getting an error, but testing it with my data earlier, it did match up with my dimension numbers, but once I write it back, it doesn't seem to auto-populate as I wished. Any other steps I may be missing?