Forum Discussion
Override filter context - multiple date tables
- 2 years ago
Hi JimJim,
You could validate directly in the measure which field the user is using with the function ISFILTERED.
VAR mSent = MAX('Date (Sent)'[YearMonthKey]) VAR mCreated = MAX('Date (Created)'[YearMonthKey]) RETURN IF( ISFILTERED('Date (Sent)'), CALCULATE( [Quote Count], ALL('Date (Sent)'), 'Date (Sent)'[YearMonthKey] >= mSent - 2 && 'Date (Sent)'[YearMonthKey] <= mSent ), CALCULATE( [Quote Count], ALL('Date (Created)'), 'Date (Created)'[YearMonthKey] >= mCreated - 2 && 'Date (Created)'[YearMonthKey] <= mCreated ) )If the user is using a field from the "'Date (Sent)'" table the ISFILTERED('Date (Sent)') function will return TRUE and do the calculation with the logic for the 'Date (Sent)' table.
If the user is using a field from the 'Date (Created)' it will use the other logic.
If the user is using both of them, it will calculate using the 'Date (Sent)' logic.
Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudo 👍
Thanks!
You can also check out my LinkedIn!
Best regards,
Jorge Pessoa
Hi JimJim ,
Although the name of the function might be misleading, the ISFILTERED takes in consideration both the usage of a table/column as a Filter/Slicer or as a Column in a matrix (because indirectly it's also applying a filter with that field)
Here is some documentation on that function https://dax.guide/isfiltered/ .
For additional help, please @ me in your reply!
Please consider marking it as a solution ✔️ or giving it a kudo 👍
Best regards,
Jorge Pessoa
You are correct, I just tested it. Thank you for your help.