Though set analysis is the way to go for this, but I assume you have other reasons to opt for If condition. If that is the case, then try something like:
Sum(If(LgrDtl.YYYYMM>=vprocess_month_Start and LgrDtl.YYYYMM <=vprocess_month_End ,LgrDtl.OD))
where _Start and _End are your date range, in your case its Last Six month date and Today's date respectively.
Hope this was helpful.