I hope you got the answer if not please find below simple steps to get the desired result.
1. Drag dimension A to Rows
2. Drag measure B to detail mark ( Highlighted in yellow refer below screenshot )
3. Change measure calculation to Max
4. Drag again measure B and select measure calculation to average
Let me know if you need more information.