We can find the maximum digit count as follows (as a calculated column):
MaxDigitCount =
VAR n = LEN ( [ID] )
VAR Digits =
ADDCOLUMNS ( GENERATESERIES ( 1, n ), "@D", MID ( [ID], [Value], 1 ) )
VAR Frequencies =
GROUPBY ( Digits, [@D], "@Freq", COUNTX ( CURRENTGROUP (), [Value] ) )
RETURN
MAXX ( Frequencies, [@Freq] )
Suppose [ID] = "899999999777". Then n = 12 and Digits is the table generated by creating a list from 1 to 12 and adding the column of digits corresponding to each of those positions.
Digits =
| Value |
@D |
| 1 |
8 |
| 2 |
9 |
| 3 |
9 |
| 4 |
9 |
| 5 |
9 |
| 6 |
9 |
| 7 |
9 |
| 8 |
9 |
| 9 |
9 |
| 10 |
7 |
| 11 |
7 |
| 12 |
7 |
Then Frequencies summarizes this table by grouping on @D and counting the number of occurrences of each distinct digit.
Frequencies =
Finally, return the maximum value in the @Freq column.
Using this, it's easy to check if the value is greater than 7. You can modify the final line to
IF ( MAXX ( Frequencies, [@Freq] ) > 7, ">7", "<=7" )