Assume:
Create two helper columns first (optional but clearer):
NumeratorValue = IF(YourTable[Type] = "A", YourTable[Value], BLANK())
DenominatorValue = IF(YourTable[Type] = "B", YourTable[Value], BLANK())
Now create the Ratio Column per row:
RowRatio =
VAR Num = CALCULATE(SUM(YourTable[Value]), FILTER(YourTable, YourTable[ID] = EARLIER(YourTable[ID]) && YourTable[Type] = "A"))
VAR Den = CALCULATE(SUM(YourTable[Value]), FILTER(YourTable, YourTable[ID] = EARLIER(YourTable[ID]) && YourTable[Type] = "B"))
RETURN
DIVIDE(Num, Den)
Then create a measure to sum all valid row-level ratios:
TotalRatioSum = SUMX(YourTable, YourTable[RowRatio])