Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi All,
MS documentation provides this example below to explain DATESMTD function:
CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), DATESMTD(DateTime[DateKey]))
My question is that per the syntax of CALCULATE function, DATESMTD seems like a Filter.
But, here it is not filtering anything. It is just changing the context of calculation to be done per month-to-date.
Then, why is DATESMTD function in the example above considered and placed as "FILTER" in CALCULATE formula?
Is FILTER not equivalent to removing items?
Solved! Go to Solution.
@Anonymous
CALCULATE function accepts the following type of parameters after the Expression.
In your MTD example it is a Table Filter expression that is applied here. CALCULATE filters the DateTime[DateKey] column with a range of dates from 1st of the month to the current date in the background when you apply DATESMTD function.
Hope this clear your question?
Articles:
https://dax.guide/calculate/
https://docs.microsoft.com/en-us/dax/calculate-function-dax
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Hi @Anonymous
It's a valid point. It all comes down to terminology. Here you should read FILTER not as the usual selection of rows operation but as filter context. The whole point of CALCULATE is evaluating the expression in a modified filter context. Each of those "FILTER" arguments described in the documentation is used for modifying the filter context and can be either a:
A) filter removal operation (such as ALL, ALLEXCEPT, ALLNOBLANKROW)
B) filter restore operation (ALLSELECTED)
C) table expression, returning a list of values for one or more columns or for an entire expanded table
Point C) would be the one at play in your DATESMTD example
Have a look at https://dax.guide/calculate/ for a more comprehensive overview
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
Hi @Anonymous
It's a valid point. It all comes down to terminology. Here you should read FILTER not as the usual selection of rows operation but as filter context. The whole point of CALCULATE is evaluating the expression in a modified filter context. Each of those "FILTER" arguments described in the documentation is used for modifying the filter context and can be either a:
A) filter removal operation (such as ALL, ALLEXCEPT, ALLNOBLANKROW)
B) filter restore operation (ALLSELECTED)
C) table expression, returning a list of values for one or more columns or for an entire expanded table
Point C) would be the one at play in your DATESMTD example
Have a look at https://dax.guide/calculate/ for a more comprehensive overview
|
Please accept the solution when done and consider giving a thumbs up if posts are helpful. Contact me privately for support with any larger-scale BI needs, tutoring, etc. |
@Anonymous
CALCULATE function accepts the following type of parameters after the Expression.
In your MTD example it is a Table Filter expression that is applied here. CALCULATE filters the DateTime[DateKey] column with a range of dates from 1st of the month to the current date in the background when you apply DATESMTD function.
Hope this clear your question?
Articles:
https://dax.guide/calculate/
https://docs.microsoft.com/en-us/dax/calculate-function-dax
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Thanks @Fowmy that explanation helped. Just a small follow-up query:
Does my explanation below make any sense? I mean does it support, counter your explanation or is it incorrect totally?
DATESMTD (DateTable[Date]) which according to CALCULATE function's syntax appears as being a filter is actually just a context. And when we hover over that FILTER part in the formula- PBI's intelligence suggests that [Filter1] "evaluates an expression in a context modified by filters". Which seem to suggest that even though if it doesn't remove (filter) items it still does calculate the expression per the context provided by DATESMTD
@Anonymous
You are right. One point on removing filters in addition to adding filters is that CALCULATE also accepts filter modifiers.
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
User | Count |
---|---|
124 | |
108 | |
99 | |
62 | |
62 |
User | Count |
---|---|
137 | |
115 | |
102 | |
71 | |
61 |