Forum Discussion

Excellove15's avatar
Excellove15
Iron Contributor
Oct 13, 2023
Solved

Relationship issue when Calendar table filtering two date columns in fact table

Hi,   I have a model where Calendar table filters communication table as below:   Here Calendar table Date column should filter communication table Created_on and Closed_on (both date colum...
  • SergeiBaklan's avatar
    Oct 14, 2023

    Excellove15 

    1) Created_On field in Communications is actually datetime. 

    Applying date format won't change datetime value, thus relationship with Date in calendar doesn't work, in the latest dates are with zero time.

    You may create another column in Communications as

    Create_On_Date = INT(Communications[Created_On])

    , apply date format if you wish (not necessary) and create relationship with calendar based on this field.

    2) You don't need another relationship on Closed_On, above is enough

    3) Not necessary but desirable to mark calendar as Date table (from 3-dots menu) with Date as a Key field; and uncheck Time Intelligence in options

    Without that when you use time intelligence function PBI builds in background hidden date tables which overload the model and actually not under your control. It's enough to use Calendar table for that (marked as date table) taking into account it covers all periods.

    Please note, if you've created measure with time intelligence most probably you need to re-create them with shifting on calendar as date table.

    4) Measures could be

    Queries Open = CALCULATE (
        COUNTROWS ( Communications ),
        Communications[Closed_On] = BLANK ()
    )
    
    Queries Closed = CALCULATE (
        COUNTROWS ( 'Communications' ),
        Communications[Closed_On] <> BLANK ()
    )

    5) With that visual looks as

Resources