To get started with, I just unhided the hidden fileds for the explanation.
Base Number is number type where the app user enter the arbtray number for the subscruction calc, i.e. N - each enum list item.
Count is just count the number of items for the list.
Base list. This is a bit of trick.
I made independent table looks like this.
Base list filed is ref type field, which refer to this table based on “Count” Fields. By doing so, we are able to generate the list such as
{1}
{1 , 1}
{1 , 1, 1} … based on the count of list items dynamically.
Then Base number dynamic list.
For this quick sample, I retrcted the max number of count = 3. The user can not select 4 and more enum list items.
App formula for this field
IFS(
[Count]=1,
list(number(index([Base List],1))*[Base Number]),
[Count]=2,
list(number(index([Base List],1))*number([Base Number]),number(index([Base List],2))*number([Base Number])),
[Count]=3,
list(number(index([Base List],1))*number([Base Number]),number(index([Base List],2))*number([Base Number]),,number(index([Base List],3))*number([Base Number]))
)
Looks complex, but not so. I think this expression self explanatory. Based on count of list and the arbitray number for the substruct calc, it will generate the dymamic list.
Lastly the result.
IFS(
[Count]=1,
list(
IF(
number(index([Base Number Dymamic List],1))-number(index([Enum List],1))>0,
number(index([Base Number Dymamic List],1))-number(index([Enum List],1)),
" "
)
)-list(" ")
,
[Count]=2,
list(
IF(
number(index([Base Number Dymamic List],1))-number(index([Enum List],1))>0,
number(index([Base Number Dymamic List],1))-number(index([Enum List],1)),
" "
),
IF(
number(index([Base Number Dymamic List],2))-number(index([Enum List],2))>0,
number(index([Base Number Dymamic List],2))-number(index([Enum List],2)),
" "
)
)-list(" "),
[Count]=3,
list(
IF(
number(index([Base Number Dymamic List],1))-number(index([Enum List],1))>0,
number(index([Base Number Dymamic List],1))-number(index([Enum List],1)),
" "
),
IF(
number(index([Base Number Dymamic List],2))-number(index([Enum List],2))>0,
number(index([Base Number Dymamic List],2))-number(index([Enum List],2)),
" "
),
IF(
number(index([Base Number Dymamic List],3))-number(index([Enum List],3))>0,
number(index([Base Number Dymamic List],3))-number(index([Enum List],3)),
" "
)
)-list(" ")
)
If the permissible “MAX” count of the list is 6, then amend the calc accordingly.
In case we are not able to put a bar for max permissible count for the list, I suppose we need to employ the Steve’s “Looping Actions” technique. But by the number of the count of list foreseeable always, we can push all the possible different case within the calculation, which make it possible to run the calc dynamically.
Hope a bit of help for you.