Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello everyone,
Here's the expression I try to use to calculate sales of last month>
=sum({<Date={"$(=date(addmonths(date#(Month&'/'&Year ,'MMM/YYYY'),-1),'MM/YYYY'))"}>}[sales])
The expression: date(addmonths(date#(Month&'/'&Year ,'MMM/YYYY'),-1),'MM/YYYY') gives the right result '01/2015'
and: sum({<Date={"01/2015"}>}[sales]) also gives the right result.
however it doesn't work if I combine them.
Can you advise please? THanks a lot!
=SUM({<Date = {'>=$(=Date(MonthStart(AddMonths(Today(),-1)),'DD/MM/YYYY'))<=$(=Date(MonthEnd(AddMonths(Today(),-1)),'DD/MM/YYYY'))'}>}sales)
or
=SUM({<Date = {'>=$(=Date(MonthStart(AddMonths(Max(Date),-1)),'DD/MM/YYYY'))<=$(=Date(MonthEnd(AddMonths(Max(Date),-1)),'DD/MM/YYYY'))'}>}sales)
What is the format of your Date field?
the format of Date field is "DD/MM/YYYY"
Month format= 'Jan','Feb' etc
Then how can you compare
DD/MM/YYYY with MM/YYYY ?
Below is wrong...
sum({<DD/MM/YYYY={"MM/YYYY"}>}[sales])
Both of them are Date, no? Could you please explain? THanks
How should I modify the set analysis so I get the sales of January?
Do i have to write sum({<Year={$(=Year(addmonths(Date#(Month&'/'&Year ,'MMM/YYYY'),-1)))},Month={$(=Month(addmonths(Date#(Month&'/'&Year ,'MMM/YYYY'),-1)))}>}sales)?
Thank!
=SUM({<Date = {'>=$(=Date(MonthStart(AddMonths(Today(),-1)),'DD/MM/YYYY'))<=$(=Date(MonthEnd(AddMonths(Today(),-1)),'DD/MM/YYYY'))'}>}sales)
or
=SUM({<Date = {'>=$(=Date(MonthStart(AddMonths(Max(Date),-1)),'DD/MM/YYYY'))<=$(=Date(MonthEnd(AddMonths(Max(Date),-1)),'DD/MM/YYYY'))'}>}sales)