Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Transforming a Calculated Column into a Variable inside a Measure

I have the following Calculated column to figure out if which rows hold the latest versions of data MaxDate = CALCULATE(MAX(ProjectsTable[Metric Date]),FILTER(ProjectsTable, Projects[Project Name]=E...
  • technolog's avatar
    2 years ago

    To transform your calculated columns into a measure, you need to adjust your DAX code to handle row context within a measure. Here's how you can create a measure that identifies the latest version of data dynamically:

    LatestValueMeasure = 
    VAR MaxDatePerProject = 
        CALCULATE(
            MAX(ProjectsTable[Metric Date]),
            ALLEXCEPT(ProjectsTable, ProjectsTable[Project Name])
        )
    RETURN
    IF(
        MAX(ProjectsTable[Metric Date]) = MaxDatePerProject,
        1,
        0
    )