Forum Discussion
Use Realated with calculate
Hi everyone, I’d appreciate your help. I’m trying to use a filter with the RELATED function inside CALCULATE, something like:
CALCULATE(COUNTDISTINCT(Id), Sales[Date] < RELATED(Orders[ExpirationDate])).
I get an error saying that the column used in RELATED doesn’t exist. I know a row context is needed, but in this case I want to avoid using FILTER to filter a whole table.
CALCULATE(
COUNTDISTINCT(Id),
Filter(
Summarize(
Orders,
Sales[Date],
Orders[ExpirationDate]
),
Sales[Date] < Orders[ExpirationDate]
)
)
3 Replies
- bhanu_gautam
Super User
ramiro_gonzalez , Use
DAX
CALCULATE(
COUNTDISTINCT(Sales[Id]),
TREATAS(
VALUES(Sales[Date]),
Orders[ExpirationDate]
)
) - Deku
Super User
CALCULATE(
COUNTDISTINCT(Id),
Filter(
Summarize(
Orders,
Sales[Date],
Orders[ExpirationDate]
),
Sales[Date] < Orders[ExpirationDate]
)
)
- AnonymousNot applicable
Hi ramiro_gonzalez,
Thanks for reaching out to the Microsoft fabric community forum.
It looks like you are facing issue in your DAX. As Deku and bhanu_gautam both responded to query, please go through the responses and mark the helpful reply as solution.
I would also take a moment to thank Deku and bhanu_gautam, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Hammad.
Community Support TeamIf this post helps then please mark it as a solution, so that other members find it more quickly.
Thank you.