Previous DAX solution was mixing up text and dates, and I wanted DAX to align with PQ solution so added few more lines to rank text and dates separately and then combine them.
Table =
VAR Temp =
ADDCOLUMNS (
ADDCOLUMNS (
VALUES ( Ibesmond[TEXT] ),
"@Clean String",
SUBSTITUTE ( SUBSTITUTE ( SUBSTITUTE ( SUBSTITUTE ( SUBSTITUTE ( SUBSTITUTE ( Ibesmond[TEXT], " ; ", "^" ), ";" , "^"), "$", "^" ), " ", "^" ), "^^", "^" ), "AA/BB", "AA^BB" )
),
"@Word Count",
1 + LEN ( [@Clean String] ) - LEN ( SUBSTITUTE ( [@Clean String], "^", "" ) )
)
VAR UpperBound =
MAXX ( Temp, [@Word Count] )
VAR GenerateSerialNumber =
SELECTCOLUMNS ( GENERATESERIES ( 1, UpperBound, 1 ), "@Serial Number", [Value] )
VAR TempCrossJoin =
CROSSJOIN ( Temp, GenerateSerialNumber )
VAR FilterSerialLessThanDelimiterCount =
FILTER ( TempCrossJoin, [@Serial Number] <= [@Word Count] )
VAR SplitString =
ADDCOLUMNS (
FilterSerialLessThanDelimiterCount,
"@Extracted Child", PATHITEM ( SUBSTITUTE ( [@Clean String], "^", "|" ), [@Serial Number] )
)
VAR FinalTable =
SELECTCOLUMNS (
SplitString,
"Final String",
VAR CurrentValue = [@Extracted Child]
VAR Result =
IF (
LEFT ( CurrentValue, 1 ) = "/",
MID ( CurrentValue, 2, LEN ( CurrentValue ) ),
CurrentValue
)
RETURN
Result
)
VAR SummarizeFinalTable =
SUMMARIZE ( FinalTable, [Final String] )
VAR PrelimResult =
ADDCOLUMNS (
SummarizeFinalTable,
"ValueCount",
VAR CurrentValue = [Final String]
VAR Result =
COUNTROWS ( FILTER ( FinalTable, [Final String] = CurrentValue ) )
RETURN
Result
)
VAR TextTable =
FILTER ( PrelimResult, NOT CONTAINSSTRING ( [Final String], "/" ) )
VAR TextTabletWithRank =
ADDCOLUMNS (
TextTable,
"Ranking",
VAR CurrentValue = [ValueCount]
VAR Result =
COUNTROWS ( FILTER ( TextTable, [ValueCount] >= CurrentValue ) )
RETURN
Result
)
VAR MaxRankOfTextTable =
MAXX ( TextTabletWithRank, [Ranking] )
VAR DateTable =
FILTER ( PrelimResult, CONTAINSSTRING ( [Final String], "/" ) )
VAR DateTableWithRank =
ADDCOLUMNS (
DateTable,
"Ranking",
VAR CurrentString =
CONVERT ( [Final String], DATETIME )
VAR Result =
COUNTROWS (
FILTER ( DateTable, CONVERT ( [Final String], DATETIME ) <= CurrentString )
)
RETURN
MaxRankOfTextTable + Result
)
VAR FinalResult =
UNION ( TextTabletWithRank, DateTableWithRank )
RETURN
FinalResult