问题
Trying to extract data from every months of the year.
I haven't seen much info on it.
I tried many formulas but nothing worked. Stuff like:
CASE {trandate} WHEN 'YYYY' = '2018' AND 'MM' = "01" then {amount} ELSE 0 END
Anyone knows how to do?
回答1:
Taking your example and correcting (note William Robertson's comment):
CASE WHEN TO_CHAR({trandate},'YYYY') = '2018' AND TO_CHAR({trandate},'MM') = '01' THEN {amount} ELSE 0 END
This will return {amount}
for every transaction in January 2018 which matches the criteria you have set. However, if you want to return amount for all months, you'd probably be better off doing something like:
- Sum by
{amount}
Group by a formula(text) field with a formula like:
TO_CHAR({trandate},'YYYY') || TO_CHAR({trandate},'MM')
This can be tweaked to give a more readable result (for instance by concatenating with a hyphen, or using month names instead of number etc.) but this should get you started.
EDIT: A better way to write the formula for the first method would be:
CASE WHEN TO_CHAR({trandate},'YYYY-MM') = '2018-01' THEN {amount} ELSE 0 END
Also - the first method is best if you want to group amounts by month into columns, whereas the second would give you amounts for each month in different rows of the result page.
来源:https://stackoverflow.com/questions/48632032/pull-out-data-from-a-specific-month-in-netsuite