Forum Discussion
Havard
5 years agoFrequent Visitor
Find if a date from API is YTD or LYTD
I'm really new to this. I can't find how to do what's marked with BOLD. I would be very happy if anyone could help med with this: if [postingDate] >= #date(ThisYear, 1, 1) and [postingDate] <= #d...
- 5 years ago
That is how you do it. The clean code would be something like this Havard
let varToday = Date.From(DateTimeZone.FixedUtcNow()) in if [postingDate] >= Date.StartOfYear(varToday) and [postingDate] <= varToday then "YTD" else if [postingDate] >= Date.AddYears(varToday,-1) and [postingDate] <= Date.AddYears(varToday,-1) then "LYTD"
Havard
5 years agoFrequent Visitor
Thx a lot! It's easier to see the "language" now.
Havard
4 years agoFrequent Visitor
I thought this worke, but does not. Can somoen pls help me? Im NO good to this;)
if [postingDate] >= Date.StartOfYear(Date.From(DateTimeZone.FixedUtcNow())) and [postingDate] <= Date.From(DateTimeZone.FixedUtcNow())
then "YTD"
else if [postingDate] >= Date.AddYears(Date.From(DateTimeZone.FixedUtcNow()),-1) and [postingDate] <= Date.From(Date.AddYears(Date.From(DateTimeZone.FixedUtcNow()),-1))
then "LYTD"
else "BLANK"