Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
shan_sriv
Contributor II
Contributor II

Date Calculation in Set Analysis

Dear Experts,

I want to calculate Sum of Sales for Previous Year Q2 which is 01-Apr-2017 to 30-Jun-2017.

In data source I have column OrderDateTime which is having date and time like "01/01/2017 11:57:00". From this column I have created a new column OrderDate which is having only dates in DD/MM/YYYY format.

For above requirement I tried following Set Analysis expression but I am getting 0 as output :

=Sum({<OrderDate = {">=Date(AddYears(QuarterStart(YearStart(Today()),1),-1),'DD/MM/YYYY') <= Date(MonthEnd(AddYears(QuarterEnd(YearStart(Today()),1),-1)),'DD/MM/YYYY') "}>}Sales)

Could you please help me in correcting this expression ?

Thanks & Regards,

Shantanu

1 Solution

Accepted Solutions
rubenmarin

Hi Shantanu, try adding a dollar-expansion to set analysis, also maybe needs to ignore other selected values like Year:

=Sum({<OrderDate = {">$(=Date(AddYears(QuarterStart(YearStart(Today()),1),-1),'DD/MM/YYYY'))<= $(=Date(MonthEnd(AddYears(QuarterEnd(YearStart(Today()),1),-1)),'DD/MM/YYYY'))"}, YearField>}Sales)


Using a numeric date field in set analysis can help to avoid format issues, the numeric field can be created as:

Num(OrderDate) as NumDate

View solution in original post

5 Replies
rubenmarin

Hi Shantanu, try adding a dollar-expansion to set analysis, also maybe needs to ignore other selected values like Year:

=Sum({<OrderDate = {">$(=Date(AddYears(QuarterStart(YearStart(Today()),1),-1),'DD/MM/YYYY'))<= $(=Date(MonthEnd(AddYears(QuarterEnd(YearStart(Today()),1),-1)),'DD/MM/YYYY'))"}, YearField>}Sales)


Using a numeric date field in set analysis can help to avoid format issues, the numeric field can be created as:

Num(OrderDate) as NumDate

YoussefBelloum
Champion
Champion

Hi,

try this (you were missing the red parts):

=Sum({<OrderDate = {">=$(=Date(AddYears(QuarterStart(YearStart(Today()),1),-1),'DD/MM/YYYY')) <= $(=Date(MonthEnd(AddYears(QuarterEnd(YearStart(Today()),1),-1)),'DD/MM/YYYY'))"}>}Sales)

shan_sriv
Contributor II
Contributor II
Author

Thanks a lot for your help Ruben.

rubenmarin

You are welcome.

Check if it should be:

=Sum({<OrderDate = {">=$(=Date(AddYears(QuarterStart(YearStart(Today()),1),-1),'DD/MM/YYYY'))<= $(=Date(MonthEnd(AddYears(QuarterEnd(YearStart(Today()),1),-1)),'DD/MM/YYYY'))"}, YearField>}Sales)

YoussefBelloum
Champion
Champion

keep in mind that with this, DAY 01/04/2017 will not be counted, so try to verify if you need it and so add this > to Ruben's expression