Forum Discussion
FUAM DataSet
I am trying to link the Activities and semantic_models tables using ArtifactId = SemanticModelId
The measure is as follows:
Last Refresh Date = VAR CurrentCalc = CALCULATE( MAX('activities'[CreationDate]), 'activities'[Operation] = "RefreshDataset", TREATAS(VALUES('semantic_models'[SemanticModelId]), 'activities'[ArtifactId]) ) RETURN IFERROR(CurrentCalc, BLANK())
Can anyone see why I am getting an incorrect date in the measure?
Hi MikeFleming
Sorry for the late response.The incorrect Last Refresh Date occurs because:
- TREATAS(VALUES(semantic_models[SemanticModelId])) can return multiple IDs
- This causes the activities table to be filtered for multiple artifacts
- MAX(CreationDate) then returns a date from an unrelated refresh
This is a filter-context ambiguity, not a data issue.
Instead of TREATAS, explicitly filter activities using a single Semantic Model ID via SELECTEDVALUE.
Last Refresh Date =
VAR SemanticModelId =
SELECTEDVALUE ( 'semantic_models'[SemanticModelId] )
RETURN
IF (
NOT ISBLANK ( SemanticModelId ),
CALCULATE (
MAX ( 'activities'[CreationDate] ),
'activities'[Operation] = "RefreshDataset",
'activities'[ArtifactId] = SemanticModelId
)
)
Let me know if the above mentioned works for you.
Thanks and regards,
Cheri Srikanth
Community Support Team.
5 Replies
- v-csrikanthCommunity Support
Hi MikeFleming
Thank you for reaching out to the fabric community.Yes, the issue is not with TREATAS itself, but with filter context and aggregation logic. Your measure is technically valid DAX, but it’s returning an unexpected MAX date because of how Power BI evaluates context.
Last Refresh Date :=
VAR CurrentCalc =
CALCULATE(
MAX ( 'activities'[CreationDate] ),
'activities'[Operation] = "RefreshDataset",
TREATAS(
VALUES ( 'semantic_models'[SemanticModelId] ),
'activities'[ArtifactId]
)
)
RETURN
IFERROR ( CurrentCalc, BLANK() )
Thanks and Regards,
Cheri Srikanth. - MikeFlemingRegular Visitor
Thanks v-csrikanth any suggestions as to how to fix?
- v-csrikanthCommunity Support
Hi MikeFleming
Sorry for the late response.The incorrect Last Refresh Date occurs because:
- TREATAS(VALUES(semantic_models[SemanticModelId])) can return multiple IDs
- This causes the activities table to be filtered for multiple artifacts
- MAX(CreationDate) then returns a date from an unrelated refresh
This is a filter-context ambiguity, not a data issue.
Instead of TREATAS, explicitly filter activities using a single Semantic Model ID via SELECTEDVALUE.
Last Refresh Date =
VAR SemanticModelId =
SELECTEDVALUE ( 'semantic_models'[SemanticModelId] )
RETURN
IF (
NOT ISBLANK ( SemanticModelId ),
CALCULATE (
MAX ( 'activities'[CreationDate] ),
'activities'[Operation] = "RefreshDataset",
'activities'[ArtifactId] = SemanticModelId
)
)
Let me know if the above mentioned works for you.
Thanks and regards,
Cheri Srikanth
Community Support Team. - v-csrikanthCommunity Support
Hi MikeFleming
I just wanted to follow up and check whether you have had a chance to verify the solutions mentioned above. Please let me know if you need any additional clarification from our end.
Thanks and regards,
Cheri Srikanth
Community Support Team. - v-csrikanthCommunity Support
Hi MikeFleming
We hope you're doing well. Could you please confirm whether your issue has been resolved or if you're still facing challenges? Your update will be valuable to the community and may assist others with similar concerns.
Thank you.