Forum Discussion
Syndicate_Admin
3 years agoAdministrator
Add rows to table that repeats unique column countdown starting from value in another column, for a set number of times.
Having trouble figuring out the direction I need to go for this table I want to make. Will continue to research functions but wanted to pose the general question to the community. I have this table...
Anonymous
3 years agoNot applicable
This almost worked. The math breaks down with larger tool life and current life values. I adjusted the function and it looks like the values are populating correctly, EXCEPT the [part_count]=1 field is not populating with a 1 where toollife=currentlife. I cannot figure out how to adjust it for that yet.
fx_tools_add_positions = (r as record, parts as number) as record =>
Record.AddField(
r,
"positions",
List.Numbers(
r[Currentlife]+1,
Number.RoundAwayFromZero(parts / r[Toollife]),
r[Toollife])
)
,
AlienSx
3 years agoSuper User
please give an example of toollife and currentlife values combination that gives wrong result (or error).
- Anonymous3 years agoNot applicable
When I input 100 for a tool life and 2 for a current life, the first "1" set for that tool was at part #98, then every 100 parts# after that.
- AlienSx3 years agoSuper User
need to change initial value in that function
fx_tools_add_positions = (r as record, parts as number) as record => Record.AddField( r, "positions", List.Numbers( if r[Toollife] = r[Currentlife] then 1 else r[Currentlife] + 1, Number.RoundAwayFromZero(parts / r[Toollife]), r[Toollife]) ),
- Syndicate_Admin3 years agoAdministrator
I got this to work now by adjusting the custom function like so:
fx_tools_add_positions = (r as record, parts as number) as record => if r[Currentlife]=r[Toollife] then Record.AddField( r, "positions", List.InsertRange( List.Numbers( r[Currentlife]+1, Number.RoundAwayFromZero(parts / r[Toollife]), r[Toollife]),0, List.Numbers(1,1) ) ) else Record.AddField( r, "positions", List.Numbers( r[Currentlife]+1, Number.RoundAwayFromZero(parts / r[Toollife]), r[Toollife]) ) ,