Forum Discussion
Calendar Table Not Functioning Properly
- 7 years ago
Use these measures:
Gross Billings $ FY 2018 = CALCULATE( [Gross Billings $], FILTER('Calendar','Calendar'[Year] = 2018) )And for the MTD:
Gross Billings $ FY18 MTD = CALCULATE( [Gross Billings $], DATESMTD('Calendar'[Date]), FILTER('Calendar','Calendar'[Year] = 2018) )The reason it works that way is when you use a simple filter in CALCULATE as you have, it wraps an ALL() around it. Read this SQLBI article on how simple filters in CALCULATE work.
The crux of it is your measure:Test = CALCULATE( [Gross Billings $], 'Calendar'[Year] = 2018 )is rewritten as this by DAX:
Test = CALCULATE( [Gross Billings $], FILTER( ALL('Calendar'[Year]), 'Calendar'[Year] = 2018 ) )So viewed that way, it is saying ignore the filter context from the matrix columns. Don't use just 2016 dates for column 2016, but use all dates, but then only show me 2018 from that. Then it does the same for 2017, 2018, 2019, etc. So only 2018 looks right to you.
I rarely use a simple filter in Calculate. I almost always use FILTER() there to ensure I have more control over what I get.
What is wrong with the output? It seems to be breaking things out by year, albiet with test data ($10/yr).
One question on the date table, it must have ALL dates in it. If it is built directly off of your invoice table, and you didn't bill every day, that will cause problems. You should have a start date, and a list of contiguious dates for however long you need it.
For example, in Power Query, this will give you a list of dates from Jan 1, 2016 through Dec 31, 2018 assuming you are running this in 2018. It uses the system clock.
let
Source = #date(Date.Year(DateTime.LocalNow())-2,1,1),
DatesAsAList = List.Dates(Source,Number.From(Date.EndOfYear(#date(Date.Year(DateTime.LocalNow())+1,1,1)))-Number.From(Source)+1,#duration(1,0,0,0))
in
DatesAsList
Also make sure both dates (calendar table and invoice table) are the same - Date, Date/Time, or Date/Time/Timezone. It cannot be a mix. You cannot successfully join Date to a Date/Time field.
If none of the above is helpful, please explain what you expect your output to be.
And post your Gross Billings $ measure. It shouldn't be more than SUM(Sales[Billings]) though unelss you have other logic in there for some reason.