It is about unreal situation in the past. We didn't take our friend with us to the party because he was not at home, so I said to him. If you had been at home, we would have taken you with us. Or We Would have taken you with us if you had been at home.
1 Answer
They're both fine.
I'd be tempted to say that the part that you put first receives slightly more emphasis.
So for example:
If you'd been at home, we would have taken you with us.
Perhaps here you are slightly annoyed that the person wasn't at home.
We would have taken you with us if you'd been at home.
Perhaps this version could sound more like you are wanting to reassure the person that you would have taken them with you, and the only reason you didn't was that they weren't at home.
This difference is subtle though, and both sentences could easily be modified by voice tone, etc.