Forum Discussion

MarkKemeny's avatar
MarkKemeny
New Member
3 years ago
Solved

RELATED () function error

Hi Guys, I have a problem with the RELATED() funcion in dax. I have a simple dimension and fact table where I have to compare date values in the fact table with the values in the dimension table: ...
  • johnt75's avatar
    3 years ago

    At the point where you are using RELATED no row context exists, so it cannot traverse the relationship. I think you want something like

    My Measure =
    VAR MaxDate =
        MAX ( dim_Deadlines[Deadline] )
    RETURN
        CALCULATE (
            COUNTROWS ( 'fct_Overview_Status_Phase_1-2-3_Promotion' ),
            'fct_Overview_Status_Phase_1-2-3_Promotion'[Date.1] < MaxDate
        )
    

    As long as some column from your dimension table is in the visual this should work.

  • v-zhangti's avatar
    3 years ago

    Hi, MarkKemeny 

     

    You can try the following methods.
    Sample data:

    One to many

    Measure = 
    CALCULATE ( COUNTROWS ( 'fct_Overview_Status_Phase_1-2-3_Promotion' ),
        FILTER ( ALL ( 'fct_Overview_Status_Phase_1-2-3_Promotion' ),
            'fct_Overview_Status_Phase_1-2-3_Promotion'[Date.1]
                < SELECTEDVALUE ( dim_Deadlines[Deadline] )
        )
    )

    Is this the result you expect?

     

    Best Regards,

    Community Support Team _Charlotte

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.