Your time in the PPR + 12 months is treated as occupation so you would have to sell it more than a year after you moved out and rented in order to offset any loss. Then you would pro-rate the loss depending on how long it was an investment property vs PPR. There are numerous threads on this if you do a search.
For example, if you owned the property for 5 years as of today, moved out now and sold in two years time, then you could claim 1/7th of the loss against your gain. The loss/gain calculation is done on a straight-line basis.