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.
Are you sorting anything by the calendar year? If so, you need to also include that in your CALCULATE filter.
Of course, if you just dropped the Gross Billing $ measure in and got rid of the others, the grid should work fine at that point. The date table will allow it to put your data in the right columns without the need for filters.
EDIT: See this file for an example of what I am talking about. This is just one measure.
edhans wrote:Are you sorting anything by the calendar year? If so, you need to also include that in your CALCULATE filter.
Of course, if you just dropped the Gross Billing $ measure in and got rid of the others, the grid should work fine at that point. The date table will allow it to put your data in the right columns without the need for filters.
EDIT: See this file for an example of what I am talking about. This is just one measure.
edhans,
Thanks so much for the pbix example.
I took it one step further and recreated the problem I'm seeing in my data, along with the formulas used.
https://i.imgur.com/3HgxNdV.png
Question #1) Shouldn't $6,551 only appear under 2018? Why do I see it across all 10 years? I see it totals properly (it doesn't take $6,551 x 10 years), but still confusing why it shows up 9 extra times.
Question #2) Shouldn't $147 only appear under 2018? Why do I see it across all 10 years? I see it totals properly (it doesn't take $147 x 10 years), but still confusing why it shows up 9 extra times.
Thanks in advance,
- edhans7 years agoCommunity Champion
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.- Anonymous7 years agoNot applicable
edhans,
If I could give you a e-highfive & e-chestbump I would.
Appreciate your sample PBIX, helped me recreate my problem for you.
Thank you very much, you are a gentleman and a scholar.<michael-scott.gif>