If you need a simple solution, use Now.AddYears(-1).ToString("yyyy") + Now.AddMonths(-1).ToString("MM") directly in the Type Into activity.
If you want better readability and debugging, assign previousPeriod = If(Now.Month = 1, Now.AddYears(-1).ToString("yyyy") + "12", Now.ToString("yyyy") + (Now.Month - 1).ToString("00")) in an Assign activity and use the variable in the Type Into activity. If you face a compilation error, the Assign method is more stable.
If you found helpful mark as solution.
Happy Automation with UiPath
PreviousMonth.zip (84.0 KB)
AddMonth() function can automatically take care of going to previous year, if the month is January. No need to explicitly use any if condition to achieve that.
I have attached a code snippet, please refer.