So INTNX('month',......) is used to move dates by a certain # of months. It also can adjust to the beginning, ending, or the sameday in that new month.
intnx('month',api_date,case when day(api_date)>=25 then 1 else 0 end,'begin') format mmddyy10. as Period,
I understood that if the api_date was between the 25th of the previous month and the 24th of the current month, that data was to be tagged as the first of the current month. That can be translated to "if the api_date is 25 or greater, move to the next month otherwise keep the current month" which is used in the intnx function as the # of months to move and use the beginning of that resulting month.
intnx('month',api_date,case when day(api_date)>=25 then 0 else - 1 end,'begin')+24 format mmddyy10. as PeriodStart,
If the api_date >= 25, move to the beginning of the current month and add 24 days (ends up on the 25th). If the api_date < 25, move to the beginning of the prior month and add 24 days (resulting in the 25th of the prior month).
intnx('month',api_date,case when day(api_date)>=25 then 1 else 0 end,'begin')+23 format mmddyy10. as PeriodEnd
if the api_date >= 25, move to the beginning of the next month and add 23 days (ends up on 24th of next month). If the api_date < 25, move to the beginning of current month and add 23 days (ends up on 24th of current month).
... View more