In 214, after Liu Bei seized control of Yi Province from Liu Zhang, he appointed Zhang Yu as a Major of the Rear Section (後部司馬) in his new administration. Around 217, when Liu Bei planned to launch a campaign to seize the strategic Hanzhong Commandery from his rival Cao Cao, he consulted Zhou Qun and asked him to predict the outcome. Zhou Qun told him that he would gain the territories in Hanzhong Commandery but not its people, and advised him to not send a detachment of his main army to attack the enemy. At the time, Zhang Yu, who was known for being better than Zhou Qun in divining the future, advised Liu Bei against launching the Hanzhong Campaign. Liu Bei ignored their advice and went ahead anyway. As Zhou Qun predicted, Liu Bei defeated Cao Cao and captured the territories in Hanzhong Commandery but not its people because they had already migrated elsewhere. During the campaign, Liu Bei also ordered Wu Lan (吳蘭) and Lei Tong (雷銅) to lead a detachment of troops from his main army to attack Wudu Commandery (武都郡; around present-day Longnan, Gansu), but, as Zhou Qun warned him, this detachment ended up being completely destroyed by Cao Cao's forces. After the successful conquest of Hanzhong, Liu Bei nominated Zhou Qun as a "maocai" (茂才; an outstanding civil servant), probably to commend him for his earlier advice, but did not do the same for Zhang Yu.