Forum Discussion
DAX formula
- 11 months ago
Hi KavithaN,
Thank you for reaching out to the Microsoft fabric community forum.
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community
Regards,
Community Support Team.
Hi KavithaN
There are a couple of issues here.
1. You're using X[AssessDate] <= MaxDate but AssessDate has an inactive relationship to Dim_Time. So MAX(Dim_Time[Date]) won't automatically filter X. You need to use 'USERELATIONSHIP' to activate the relationship.
2. You want to filter 2 assignments, but you're currently using [EventCount] >= 1, this should be 2
Here's the revised DAX:
VAR MaxDate = MAX(Dim_Time[Date])
VAR IDswithTwoAssessments =
FILTER(
ADDCOLUMNS(
VALUES(X[RID]),
"EventCount",
CALCULATE(
DISTINCTCOUNT(X[IDEvent]),
REMOVEFILTERS(Dim_Time),
USERELATIONSHIP(X[AssessDate], Dim_Time[Date]),
X[AssessDate] <= MaxDate
)
),
[EventCount] >= 2
)
VAR Result =
CALCULATE(
DISTINCTCOUNT(Y[RID]),
REMOVEFILTERS(Dim_Time),
Y[RDate] <= MaxDate,
ISBLANK(Y[DDate]) || Y[DDate] > MaxDate,
TREATAS(
SELECTCOLUMNS(IDswithTwoAssessments, "RID", [RID]),
Y[RID]
)
)
RETURN Result
I hope this helps, please mark as solved if it does!
kudos always welcome .
Connect with me on LinkedIn
Subscribe to my YouTube channel for Fabric/Power Platform related content!