Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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:
CALCULATE(COUNTROWS('fct_Overview_Status_Phase_1-2-3_Promotion'), 'fct_Overview_Status_Phase_1-2-3_Promotion'[Date.1]<RELATED(dim_Deadlines[Deadline])).
It gives me the error that "The column 'dim_Deadlines[Deadline]' either doesn't exist or doesn't have a relationship to any table available in the current context."
The two tables are connected with a 1 to many relationship so I dont understand what is the problem.
When I create a conditional column in the fact table using the RELATED() function it works fine, but when I am using that inside a DAX measure it gives me this error.
Thanks,
Mark
Solved! Go to Solution.
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.
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.
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.
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.
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
13 | |
11 | |
9 | |
6 |