Novel x-ray spectroscopies such as high-resolution x-ray absorption (XAS) performed in the partial fluorescence yield mode (PFY), and resonant emission (RXES) offer new opportunities to probe the bulk electronic configuration in strongly correlated systems. We performed an Yb L-3 PFY-XAS and RXES investigation of the intermediate valence compound YbAl2 under external pressure. We found that the Yb valence increases from 2.25 at ambient pressure to 2.9 at 385 kbar. This experiment has extended the range of pressures explored until now, in order to cover the whole valence transition, which we find to be completed around 200 kbar. Moreover, the new data considerably reduce the experimental error bars on previous estimates and provide the most accurate description to date of this transition. We discuss the relative merits of various approaches to extract the 4f occupancy from the spectroscopic data.