Forum Discussion

AlanBaker's avatar
AlanBaker
Frequent Visitor
9 years ago
Solved

Time Intelligence - Data Table Relationship with CALENDAR date not working

Hi I have what appears to be the same issue previously reported , I have Created a Calendar Table with a Unique ID which I am using to perform Date Intelligence in order to determine planned costs...
  • TomMartens's avatar
    TomMartens
    9 years ago

    Hey AB,

     

    each measure is evaluated in the so called Filter Context. The Filter Context filters down the table used in the expression, in your example this is the table KPI2_... This means before the expression is evaluated the current Current Filter context is applied to the table. The Filter Context is determined by the selections made from the slicers and also by the row and column headers. After the Filter Context is applied the expression is evaluated to the remaining rows, this explains why we always (at least most of the time have to aggregate functions like SUM('KPI2_...'[PlannedCosts]). This becomes different if we use iterator funtions like SUMX() and the lot. To me it seems, that most measures I calculate require that this Filter Context has to be adjusted. This adjustment is possible if we us CALCULATE(<expression>, FITLER1,...FILTERn).

     

    If you use the Date column from your Calendar table something called Filter Propagation happens. The current selection from the Calendar table is propagated to the many side of an existing relationship.

     

    The working linkage of your Calendar table and your fact table 'KPI2_...' is demonstrated by the 1st table of your screenshot.

     

    If you use the Date column from the table 'KPI2_...' this selection is used to filter this table and the [PlannedCosts] column in your first post shows the correct value (the 2nd table in your screenshot).

     

    If you use the Date column from the table 'KPI2_..." in your table visual, there is no filter on the Calendar table for this reason the FILTER(...) will always return the same table containing the last 7 seven days of your Calendar table. This table is then used to Filter down your 'KPI2_' table. I assume that there are no values available in your table 'KPI2_...' for these last 7 days, for this reason no value is shown for your measure LASTWEEK_PLAN_COSTS 

     

    You may reconsider using the Calendar table for your visuals from my experience this is a common practice, if you won't or can't then you have to rewrite your measure to use your Date column from your table 'KPI2_...'.

     

    In addition to Matt Allington's book I also recommend the following books from Marco Russo and Alberto Ferrari

    • Analyzing Data with Microsoft Power BI and Power Pivot for Excel
    • The Definitive Guide to DAX

     

    Regards

  • AlanBaker's avatar
    AlanBaker
    9 years ago

    Thanks Tom, you make perfect sense and thankyou for taking the time to make the detailed explanation :-) (BTW I have also purchased a copy of Marco & Alberto's "The Definitive Guide to DAX"

     

    Regards

     

    AB