Forum Discussion
BoBBie
7 years agoFrequent Visitor
ytd multipe years
I have a database with all sales data from 2012 (inclusing a seperate date table). I want to display the sales orders amount of current year to date (data is updated / synct daily) including all prev...
- 7 years ago
solved by searching the community YTD untill today thanks to OwenAuger
YTD Values till last orderdate = VAR LOD = [Last Order Date] VAR TodayMonth = MONTH ( LOD ) VAR TodayDay = DAY ( LOD ) VAR YearDateFilter = GENERATE ( VALUES ( 'date table'[year] ); VAR TodayInCurrentYear = DATE ( 'date table'[year] ; TodayMonth; TodayDay ) RETURN CALCULATETABLE ( DATESYTD ( 'date table'[Date] ); TREATAS ( { TodayInCurrentYear }; 'date table'[Date] ) ) ) RETURN CALCULATE ( DISTINCTCOUNT(Blad1[orderno]); KEEPFILTERS ( YearDateFilter ) )and
YTD-PY values till last order date = CALCULATE([YTD Values till last orderdate];SAMEPERIODLASTYEAR('date table'[Date]))
BoBBie
7 years agoFrequent Visitor
parry2k
7 years agoSuper User
BoBBie try following two measures and I guess this will get you the result
first calculated the all time last order date:
Last Order Date = CALCULATE( max( Blad1[orderdate] ), ALL( Blad1 ) )
Create last ytd order count based on last order date, in this measure we will calculate the date for each year and filter orders until that date, feel free to change the measure to meet you need.
ytd-2 =
VAR currentYear = MAX( 'date table'[year] )
VAR currentYearLastDate = DATE(currentYear, MONTH( [Last Order Date] ), day( [Last Order Date] ) )
RETURN
CALCULATE( [ytd], 'date table'[Date] <= currentYearLastDate )