Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
brianlarson
Frequent Visitor

DAX calculatetable not filtering on related date table

In my model, I have a table called Date with a relationship with a table called IntegrityExceptions.  Date.FullYear has a realtionship with IntegrityExceptions.Exception Date In.  I have created a table like this:

Table 3 =
var yr = MAX('Date'[Year])
RETURN
CALCULATETABLE(IntegrityExceptions,'Date'[Year] = 2021,'Date'[Quarter] = 2)
 
As I have it above, it returns results but if I change it be:
 
Table 3 =
var yr = MAX('Date'[Year])
RETURN
CALCULATETABLE(IntegrityExceptions,'Date'[Year] = yr'Date'[Quarter] = 2)
 
It doesn't return any results even though MAX('Date'[Year]) is equal to 2021 based on my date slicer on the canvas.  I can't figure out why it doesn't work. 
 
1 ACCEPTED SOLUTION

You can wrap the CALCULATETABLE in a COUNTROWS function and use the resulting measure as a filter for the visual in the filter pane setting the value to greater or equal to 1.

Something along the lines of:

 

 

Table 3 =
VAR yr =
    MAX ( 'Date'[Year] )
RETURN
    COUNTROWS (
        CALCULATETABLE ( IntegrityExceptions, 'Date'[Year] = yr, 'Date'[Quarter] = 2 )
    )

 

 

 

However, if you need to calculate values for other periods based on date slicers, it is highly recommended you create a date table with continuous dates covering the range of dates in the model. You can then use Time Intelligence functions for the calculations





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

3 REPLIES 3
brianlarson
Frequent Visitor

Thanks Paul.  What would be a way to have a filtered table based on what is selected in the slicers?  I need to be able to create a data set that time travels, one quarter ago, two quarters ago, etc. 

You can wrap the CALCULATETABLE in a COUNTROWS function and use the resulting measure as a filter for the visual in the filter pane setting the value to greater or equal to 1.

Something along the lines of:

 

 

Table 3 =
VAR yr =
    MAX ( 'Date'[Year] )
RETURN
    COUNTROWS (
        CALCULATETABLE ( IntegrityExceptions, 'Date'[Year] = yr, 'Date'[Quarter] = 2 )
    )

 

 

 

However, if you need to calculate values for other periods based on date slicers, it is highly recommended you create a date table with continuous dates covering the range of dates in the model. You can then use Time Intelligence functions for the calculations





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






PaulDBrown
Community Champion
Community Champion

CALCULATETABLE is a function which creates a table. Calculated (physical) tables are loaded when the model is loaded and are oblivious to slicers (you can check by hard-coding the date in the CALCULATETABLE function to see how it loads)





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.