Yea, the action block method is great, but will not work in this case, because this statement is with a Select action. I was going to be happy with the nested if(), which worked great for one condition. However, now I have the need to detect if the first SIX characters of a string constitute a number. That will break the lexicographical order idea. Which was a good one, btw. But things have become more complex.
What I am actually doing, is moving this condition statement to create another data column in a Flow Select action. This is the statement in powerapps:
If(StartsWith(OrderNumOB,"Kel"),2,
StartsWith(OrderNumOB,"RMA"),3,
StartsWith(ProductID,"HF"),5,
StartsWith(ProductID,"DC"),5,
StartsWith(ProductID,"NW"),5,
IsMatch(ProductID,Match.Digit) And Mid(ProductID,2,1)="-",5,
StartsWith(ProductID,"BT"),5,
StartsWith(ProductID,"K") And IsNumeric(Mid(ProductID,2,1)),4,
IsMatch(ProductID, Match.Digit & Match.Digit & Match.Digit & Match.Digit & Match.Digit & Match.Digit),4,1)
This is what I have so far in an expression. This works perfectly at this point. However, I need to add the last two lines from above, into the expression.
if(startsWith(item()?['OrderNumOB'],'Kel'),2,
if(startsWith(item()?['OrderNumOB'],'RMA'),3,
if(startsWith(item()?['ProductID'],'HF'),5,
if(startsWith(item()?['ProductID'],'DC'),5,
if(startsWith(item()?['ProductID'],'NW'),5,
if(startsWith(item()?['ProductID'],'BT'),5,
if(and(
equals(
if(equals(substring(item()?['ProductID'],0,1),'0'),1,
if(equals(substring(item()?['ProductID'],0,1),'1'),1,
if(equals(substring(item()?['ProductID'],0,1),'2'),1,
if(equals(substring(item()?['ProductID'],0,1),'3'),1,
if(equals(substring(item()?['ProductID'],0,1),'4'),1,
if(equals(substring(item()?['ProductID'],0,1),'5'),1,
if(equals(substring(item()?['ProductID'],0,1),'6'),1,
if(equals(substring(item()?['ProductID'],0,1),'7'),1,
if(equals(substring(item()?['ProductID'],0,1),'8'),1,
if(equals(substring(item()?['ProductID'],0,1),'9'),1,
0)))))))))),
1),
equals(substring(item()?['ProductID'],1,1),'-')),5,
0))))))