cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Frequent Visitor

## sales per yaer vs sales YTD

Hi i'm, using a sales report with an overview of the last 5 years.

to have the numbers i'm using this :

sales current year = CALCULATE([Totale sales],'Boekjaar'[Calendar Year] = YEAR(TODAY()))
sales previous year = CALCULATE([Totale sales],'Boekjaar'[Calendar Year] = YEAR(TODAY()) -1)
sales -2 = CALCULATE([Totale sales],'Boekjaar'[Calendar Year] = YEAR(TODAY()) -2)
...

Now i want to have the same for YTD. This because when i'm looking to the report today you are only able to compare month that are complete. for example december will not be comparable at this time.

thanks for the help
1 ACCEPTED SOLUTION
Super User

Pls try again

``````CurrentYear =
VAR _EndDate = EOMONTH(TODAY(),-1)
VAR _StartDate = Date(YEAR(_EndDate) ,1,1)
RETURN
CALCULATE( [Totale sales], DATESBETWEEN('Calendar'[Date],_StartDate,_EndDate))
-----
Last 1 Year =
VAR _EndDate = EOMONTH(TODAY(),-1)
VAR _StartDate = Date(YEAR(_EndDate) ,1,1)
RETURN
---------
Last 2 Year =
VAR _EndDate = EOMONTH(TODAY(),-1)
VAR _StartDate = Date(YEAR(_EndDate) ,1,1)
RETURN

6 REPLIES 6
Super User

pls try this

``````CurrentYear =
VAR _EndDate = EOMONTH(TODAY(),-1)
VAR _StartDate = Date(YEAR(_EndDate) ,1,1)
RETURN
CALCULATE( [Totale sales], DATESBETWEEN(('Calendar'[Date],_StartDate,_EndDate))
-----
Last 1 Year =
VAR _EndDate = EOMONTH(TODAY(),-1)
VAR _StartDate = Date(YEAR(_EndDate) ,1,1)
RETURN
---------
Last 2 Year =
VAR _EndDate = EOMONTH(TODAY(),-1)
VAR _StartDate = Date(YEAR(_EndDate) ,1,1)
RETURN
``````

Super User

Sorry, I edited the measure, check it again

``````CurrentYear =
VAR _EndDate = EOMONTH(TODAY(),-1)
VAR _StartDate = Date(YEAR(_EndDate) ,1,1)
RETURN
CALCULATE( [Totale sales], DATESBETWEEN(('Calendar'[Date],_StartDate,_EndDate))
-----
Last 1 Year =
VAR _EndDate = EOMONTH(TODAY(),-1)
VAR _StartDate = Date(YEAR(_EndDate) ,1,1)
RETURN
---------
Last 2 Year =
VAR _EndDate = EOMONTH(TODAY(),-1)
VAR _StartDate = Date(YEAR(_EndDate) ,1,1)
RETURN
Frequent Visitor

Probably a noob question but i'm getting:

Operator or expression '()' is not supported in this context.

``````Last 1 Year YTD =
VAR _EndDate = EOMONTH(TODAY(),-1)
VAR _StartDate = Date(YEAR(_EndDate) ,1,1)
RETURN

Super User

Pls try again

``````CurrentYear =
VAR _EndDate = EOMONTH(TODAY(),-1)
VAR _StartDate = Date(YEAR(_EndDate) ,1,1)
RETURN
CALCULATE( [Totale sales], DATESBETWEEN('Calendar'[Date],_StartDate,_EndDate))
-----
Last 1 Year =
VAR _EndDate = EOMONTH(TODAY(),-1)
VAR _StartDate = Date(YEAR(_EndDate) ,1,1)
RETURN
---------
Last 2 Year =
VAR _EndDate = EOMONTH(TODAY(),-1)
VAR _StartDate = Date(YEAR(_EndDate) ,1,1)
RETURN

Frequent Visitor

ok thanks for the reply, the formula is working but i'm not getting the desired result.

The result that i'm looking for will show me the sales for the same period

so i think we need to work in days.
IF today is day 320

Then the numbers for previous years should also be showing until day 320

Year 1 : total sales untill today (sum of 320 days)

Year -1 :  total sales upon same day as today (sum of 320 days of year-1)

...

Super User