Any miter and bevel angles may be solved by extracting and developing the tetrahedron of the compound angle . The process is exactly the same as the development of a Hip roof, here's a comparison of the mathematical models .

This is one method of analysing the geometry of the Purlin meets Valley Rafter Intersection .
Translation so you can cross reference with the diagrams in the "Tools" link:
"Sheathing Angle" or "Angle of Saw Travel" is 90° – P2
"Backing Angle" is C5
"Angle on Adjoining Face" is 90° – P1
"Mortise Layout Angle on Hip Rafter" is 90° – R2
"Saw Blade Bevel along angle on face perpendicular to surface of Roof" is C1

The lengths of the sides of the tetrahedron may be expressed in terms of trig functions of the angles to find formulas. If you aren't comfortable with trigonometry the Pythagorean Theorem will work fine, or just pull the measurements of the angles directly from the development.

Another related method:
Development of Purlin Compound Angle on the Stick .

Can you post a picture of what you are making? I'm assuming that the joint in question is similar to those in the image above. If your "Valley beam" is a layover then the compound angles at the purlin to Valley intersection will be different.