List of dates (Every 2 weeks) that includes the first of the month as well - date

I am trying to come up with a simple formula that I can extend infinitely to show me a list of dates that is separated by 2 weeks (14 days) and also includes the first of the month. The 2 weeks part is easy to accomplish with:
=A2+14
Where A2 has a date in the field to start the calculations. Then I can extend that down the column to have:
=A3+14
=A4+14
And so on... The hard part is, I also want to include the first of each month. So the list should include every other Friday and the first of the month dynamically. So the results would be like this:
2/28/2020
3/01/2020
3/13/2020
3/27/2020
4/01/2020
4/10/2020
As you can see from this list, it looks at every other Friday AND the first of the month is included in the results. I tried something like this:
=IF(MONTH(A3+14)>MONTH(A3),eomonth(A3+14,-1)+1,A2+14)
The issue from this one is that if the first of the month condition gets selected, the next date is 14 days AFTER the first of the month. It should be 14 days after the previous Friday.

try:
=ARRAYFORMULA(SORT(UNIQUE({
EOMONTH(ROW(INDIRECT(C1&":"&C2)), 0)+1;
FILTER(ROW(INDIRECT(C1&":"&C2)),
MOD(ROW(INDIRECT("A1:A"&DAYS(C2, C1)+1)), 14)=0)+1})))

Related

How to horizontally use an arrayformula to increment the week number based on a range of days?

https://docs.google.com/spreadsheets/d/1Z9Wn9Kpe7nAR4nwfpPSNtvIAOkTtTp7IxV7WHp9a84M/edit?usp=sharing
I have a spreadsheet for the year. Every day is represented as its date and as its day of the week (bleu rows in the above spreadsheet). There is a blank column at the beginning of every month (ie, the "Febuary" column (greyed out in the above spreadsheet) doesnt increment the day of the week or the date).
What I want to do is, I want to look at either the day of the week or the date and write in above Sundays the week number. So "Wk01, Wk02, Wk03" up to Wk52. An example is marked in red on the link above. These "Wk"s would have 6 blanks between them (or 7 if the week is across the greyed out month column).
Use weeknum(), like this:
=arrayformula( if( B11:11 = "Sun", "Wk" & weeknum(B12:12), iferror(1/0) ) )

How do we calculate difference and percent difference between two columns in tableau

]Difference and percent Difference must be calculated.
I cannot do Apr20-MAy20 because it is not always the same. I need to show the current month and previous month
So I did a relative filter to just show the current month and previous month.
So the difference of two columns should automatically change when the month changes.
Now how do I get the same month of prior year, how do I filter ?
I also need to calculate the difference of current year same month and previous year same month.
Thank you in advance for any help!
When I do table across difference, the difference value is overwriting the existing May and Apr month values as the below screen shot, how to show the difference in another column
Currently:
Below is Expected:
Sounds like you should create a custom filter for the dates. You want:
This month this year
This month last year
Last month this year
There are a number of ways you could do this. I'll give one example and will assume there aren't any future dates in your data set.
[DateFilter]: DATETRUNC('month',[YourDateField])>=DATETRUNC('month',DATEADD('month',-1,TODAY())) OR DATETRUNC('month',[YourDateField])=DATETRUNC('month',DATEADD('year',-1,TODAY()))
Put the to the filters shelf, set to True, and it should keep the months you want.
Then you can just use the standard table calculations to calculate Difference and Percent Difference.
Note, the formula isn't tested, just typed directly into here, let me know if it doesn't work
Based on your comments look at creating separate calculations for to YoY / MoM / etc calculation. That also means creating calculated fields to isolate the Current Month, Previous Month, etc.
For example, the current month:
[isCM]: DATETRUNC('month',[YourDateField]) = DATETRUNC('month',TODAY())
The previous month:
[isPM]: DATETRUNC('month',[YourDateField]) = DATETRUNC('month',DATEADD('month',-1,TODAY()))
Then month on month, something like:
[MoM]: (SUM([Measure])*INT([isCM]))/(SUM([Measure])*INT([isPM]))
To make your table check this article about using the placeholder technique to create tables in Tableau

how to count week number of month using dataprep

I tried to count week number of month using below code,but I got weird num like -48.(I know my logic is weird lol)
Could you point out the fault of below code to make weeknum of month.
I need sensei's help.
I used Dataprep
WEEKNUM(date)-WEEKNUM(DATE(YEAR(date),MONTH(date),1))
no error , but some values are -48,47......
Your logic is mostly sound, except you're only thinking of WEEKNUM in the context of a single year. In order to have non-overlapping weeks, the week containing January 1 is always week 1 (regardless of the period), so in this case December 29–31, 2019 are all going to be week 1, just like the following 4 days of January will be. It makes sense, but only when you think about it in context of multiple years.
You can work around this for your case by checking the WEEKNUM and MONTH values conditionally, and then outputting a different value:
IF(AND(MONTH(date) == 12,WEEKNUM(date) == 1),53,WEEKNUM(date)) - WEEKNUM(DATE(YEAR(date),MONTH(date),1))
While hard-coding the week number of 53 is a little hacky, the whole point of week numbers is to always have 52 subdivisions—so I don't really see any concerns there.
You may also want to add 1 to the resulting formula (unless you want your week numbers to start with 0 each month).

Recurring calendar event on First of the month

I have a recurring calendar event on 1st of each month, when 1st falls on Sat/Sun is it possible for iCal to schedule it for last working day Fri?
If I understood you correctly the following RRULE should do the trick:
FREQ=MONTHLY;BYDAY=1MO,1TU,1WE,1TH,1FR,-1FR;BYMONTHDAY=1,-1,-2
See the next 100 instances
It basically does two things:
Iterate the first weekday that falls on the 1st day of the month
Iterate the last Friday of each month that falls on the last or 2nd last day of the month (in which cases the 1st of the next month falls on Saturday or Sunday).
A slightly shorter version that should yield the same results is
FREQ=MONTHLY;BYDAY=1MO,1TU,1WE,1TH,FR;BYMONTHDAY=1,-1,-2
This just iterates every Friday, but only keeps the ones that fall on the first, last and 2nd last day of each month. Though it looks like the recurrence expansion service above disagrees. That's probably a bug.
I'm assuming you mean "the last working day Friday of the previous month", in which case I don't think it possible. It would mean that some months have 2 occurrences when others have 0, which doesn't really work.
You could easily do the first working day of the month (the 1st, or the first Monday):
FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=1
Or, you could do always the last working day of the month:
FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1

EOM date for various months

I'm looking to get a snapshot of inventory for the latest date of each month.
I.E.
Feb 13
Jan 14
Feb 14
There are duplicate variables - i.e., "a" will be listed several times each month. I need to get a.) the sum of each month (easy), and b.) the snapshot of the last date available.
Part B.) is what I'm having trouble with. I've seen the EOM excel formula - but it requires entering (current, following month, etc.). I just want the formula to spit out the inventory Quantity for the last date of each month, without having to specify which month (current, following, etc.).
Any ideas?
Thanks!
I'm assuming that your data is structured something like this:
http://i.stack.imgur.com/mF3h0.png
If that is the case, you can use a formula like this:
=VLOOKUP(EOMONTH(A12,0),$A$2:$B$5,2,FALSE)
Where A12 is the month you want to find the answer for. So the full sheet looks like this:
http://i.stack.imgur.com/GR5ok.png
As you can see, the formula that I put into cell B12 and then just dragged down is pulling back the correct values for the end of month inventory count. Just populate column A with the month-year you are searching for.
Hope this helps!