Hi @Anonymous,
Could you please share a bit more about your scenario?
For your first question, do you want to retrieve the occurances of commas existed on a string (e.g "a,b,c,d")?
If you want to retrieve the occurances of commas existed on a string (e.g "a,b,c,d"), I think the Split function could achieve your needs. I have made a test on my side, please take a try with the following workaround:
In order to retrieve the number of commas existed within a string, set the Text property of the Label control to following formula:
CountRows(Split(TextInput1.Text,","))-1
On your side, you should type the following formula:
CountRows(Split(TestString,","))-1
Note: The TextString represents the String X that you mentioned.
For your second question, do you want to loop the character separated via a comma within the TestString (X)?
If you want to loop the character separated via a comma within the TestString (X), I think the ForAll function (the only way to achieve a loop within PowerApps currently) could achieve your needs.
More details about ForAll function in PowerApps, please check the following article:
ForAll function
For your third question, do you want to build a string (e.g. {Text: "a", Val:1} ) using a loop and psss it as a parameter to Table() function?
In addition, If you want to achieve your needs using Table function, I afraid that there is no way to achieve your needs within PowerApps currently. Because the Set(Counter, Counter + 1) formula could not invoked within the ForAll function.
As an alternative solution, you could consider take a try to use a Collection to achieve your needs instead of Table function. I have made a test on my side, please take a try with the following workaround:
Set the OnSelect property of the "Build String" button to following formula:
Clear(TestString);
ForAll(
Split(TextInput1.Text,","),Collect(TestString,{Text:Result,Val:CountRows(TestString)+1})
)
On your side, you should type the following formula:
Clear(TestString);
ForAll(
Split(X,","),Collect(TestString,{Text:Result,Val:CountRows(TestString)+1})
)
Note: The X represents the variable X that you mentioned.
Best regards,
Kris