Forum Discussion

selected_'s avatar
selected_
Icon for Helper IV rankHelper IV
2 years ago

How to create a calculated column from a measure

I wanna display the latest rating given to an employee. In my data, I have columns 'rating' and 'reviewEndDate' in the 'doc' table, and a 'terminationDate' column in the 'employment' table. I want to return the latest rating record, but only if the termination date is greater than the review end date.

 

the table data look like this:

 

as you can see, an employee can have multiple rating record but I'm only intrested in the latest rating and reviewEndate that employee got rating which in this case are rating 1. there are cases or records that that reviewEndate higher than the terminationDate but those should be excluded since terminationDate should be higher than reviewEndDate. 

 

 

I managed by creating a measure for that as you can see below and it works fine in a table visual but I  can't put that measure in Legend or Axis in a bar chart so instead i wanna create a calculated column inside the table but when I do it with same measure then I get only one value record in all rows. 

 

what should i do or how to fix it?

 

Rating = 
VAR MaxDate = MAX('doc'[reviewEndDate])
RETURN
IF(NOT ISBLANK(MaxDate),
CALCULATE(
LASTNONBLANK('doc'[rating], 1),
FILTER('doc', 'doc'[reviewEndDate] = MaxDate)
        )
    )

  

1 Reply

  • Dangar332's avatar
    Dangar332
    Icon for Resident Rockstar rankResident Rockstar

    Hi, selected_ 

    try below

    Rating = 
    VAR MaxDate = 'doc'[reviewEndDate]
    RETURN
    IF(NOT (ISBLANK(MaxDate)),
    CALCULATE(
    LASTNONBLANK('doc'[rating], 1),
    FILTER('doc', 'doc'[reviewEndDate] = MaxDate)
            )
        )